01 2012 档案
二分查找: 最右、最左、随机
摘要:#include <iostream>#include <cstdlib>using namespace std;// return the right mosttemplate<class T>size_t bs1(T *p, size_t N, T key){ size_t low = 0, up = N; /* assert: p[low] <= key && p[up] > key && low < up */ while(low + 1 != up) { size_t mid = low + (up 阅读全文
posted @ 2012-01-01 00:21 TGW 阅读(438) 评论(0) 推荐(0)