折半查找
来源:互联网 发布:淘宝店铺的定位 编辑:程序博客网 时间:2024/06/17 13:21
本博客不再更新,更多精彩内容请访问我的独立博客
1.折半查找的非递归算法
int BinarySearch(SeqList &L,DataType x){ int high=L.n-1,low=0,mid; while(low<=high){ mid=(low+high)/2; if(x.key>L.data[mid].key) low=mid+1; else if(x.key<L.data[mid].key high=mid-1; else return mid; }return -1;};
2.折半查找的递归算法
int BinarySearchRecur(SeqList& L,DataType x,int low,int high){int mid=-1;if(low<=high){mid=(low+high)/2;if(x.key>L.data[mid].key)mid=BinarySearchRecur(L,x,mid+1,high);else if(x.key<data[mid].key)mid=BinarySearchRecur(l,x,low,mid-1);}return mid;};
1 0
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 异常处理的随笔
- 【Hadoop】7、Hadoop1.2.1基于虚拟机中的CentOS6.6的Hadoop单节点安装
- MongoDB基本语法
- jsp显示java后台的异常
- 【牛腩】网页验证码
- 折半查找
- 快速幂取余
- Qt 出现“undefined reference to `vtable for”原因总结
- Android Fragment 真正的完全解析(下)
- 我们该如何理解矩估计???
- 使用eclipse编译和管理live555源码
- 大数据算法学习笔记(2):大数据算法
- VS2012中配置OpenCV 2.4.9 死亡笔记
- 2015062805 - EffactiveJava笔记 - 第41条 慎用重载(1)