查找
顺序查找
int SequenceSearch(int a[], int n, int key) { int i=0; while(i < n && a[i] != key){ i++; } return i==n ? -1 : i; }
二分查找
int BinarySearch(int a[], int n, int key) { int low, high, mid; low = 0; high = n-1; while(low <= high) { mid = low + (high - low)/2; if (a[mid] == key) { return mid; } else if (a[mid] > key){ high = mid -1; } else { low = mid + 1; } } return -1; }
二叉排序树
平衡二叉树
多路查找
哈希表
如需转载,请注明文章出处,谢谢!!!