目录
折半查找法:每次将待查记录所在区间缩小一半。
1.折半查找的非递归算法
int Search_Bin(SSTable ST,KeyType key){
int low=1;
int high=ST.length;
while(key!=ST.R[mid].key){
if(key>ST.R[mid].key) low=mid+1;
else high=mid-1;
mid=(low+high)/2;
if(low>high) return 0;
}return mid;
}
2.折半查找的递归算法
int Search_Bin(SSTable ST,KeyType key,int low,int high){
if(low>high) return 0;