- 博客(12)
- 收藏
- 关注
转载 那些优雅的数据结构(1) : BloomFilter——大规模数据处理利器
Repost From: http://www.cnblogs.com/heaad/archive/2011/01/02/1924195.html 本文是我一个雄心勃勃的写作计划的开始:1.Bloom Filter2.线段树3.树状数组4
2011-10-05 22:18:36
388
原创 生成全排列、非全排列、组合
#include --- --- --- --- --- --- 生成全排列(递归) --- --- --- --- --- ---参数解释:s[]:需要生成排列的数组,m:起始下标,n:结束下标--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---void perm(int s[],int m,in
2009-10-17 11:22:00
778
转载 求最大、最小值的高效算法
void MaxMin(int a[], int n){ int max,min,s,i; //s为循环起始元素的下标 if (n if (n == 1) max = min = 0; else { //n为奇数时,max和min初值为第0个元素 if (n%2) {max = min = 0; s
2009-10-16 18:23:00
1664
原创 二叉搜索树的查找、插入、删除
#include #include struct node //节点的数据结构{ int data; struct node *left; struct node *right; }; --- --- --- --- --- --- --- 查 找 --- --- --- --- --- --- ---void BST
2009-10-16 18:20:00
638
原创 最大堆的插入、删除、初始化
#include int CurrSize,MaxSize; //以下均假设数组第0个元素不使用--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---插入:先插到最后面,然后循环地与父节点比较,在这个过程中把元素一层层下移,直到找到合适的位置插入 --- --- --- --- --- --- ---
2009-10-16 18:17:00
2617
1
原创 有序单向链表的相关操作
#include #include struct node //节点的数据结构{ int num; struct node *next; }; --- --- --- --- --- --- --- 插 入 --- --- --- --- --- --- ---struct node *insert_node(struct node *hea
2009-10-16 18:14:00
439
原创 二叉树相关操作
#include #include struct node //节点的数据结构{ int data; struct node *left; struct node *right; }; --- --- --- --- --- --- 前 序 遍 历 --- --- --- --- --- ---void PreOrder
2009-10-16 18:07:00
429
转载 最大公约数
int gcd(int m, int n) { int rem; while(n != 0) { rem = m % n; m = n; n = rem; } return m; } void main() { printf("%d/n",gcd(8, 1
2009-10-16 18:05:00
376
转载 折半查找 (二分查找)
int binarySearch(int s[], int n, int x) { int low = 0, high = n-1; while(low { int mid = (low + high) / 2; if(s[mid] low = mid + 1; else if(s[m
2009-10-16 17:55:00
534
原创 打印斐波那契数列
--- --- --- --- --- --- ( 循环 ) --- --- --- --- --- --- void FSum(int n){ int a = 0,b = 1,sum,i; if (n >= 1) { sum = a; printf("%d ",sum); } if (n >= 2) { sum = b;
2009-10-16 17:45:00
538
原创 生成一个整数集合的所有子集
void subset(int s[],int f[],int m,int n){ int i; f[m] = 0; //标记该元素出现 if (m == n) { printf("{"); for(i = 0; i { if (f[i] == 0) printf(" ");
2009-10-16 17:39:00
608
原创 5种基本排序法
#include --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---计数排序: a[i]与后面的每个元素相比,若a[i]较大则Count[i]+1,否则对方+1 --- --- -
2009-10-16 17:08:00
455
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人