折半查找
来源:互联网 发布:养比特犬体验知乎 编辑:程序博客网 时间:2024/06/11 02:45
折半查找:
public static int binarySearch(int[] arr, int key) { int low = 0; int high = arr.length - 1; while (low <= high) { int mid = (low + high) / 2; if (arr[mid] == key) { return mid; } else if (arr[mid] > key) { high = mid - 1; } else { low = mid + 1; } } return -1;}
阅读全文
0 0
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 折半查找
- 中国债券信息网——债券募集说明书
- Device Tree(二):基本概念
- CodeForces 165C Another Problem on Strings(公式推导)
- Docker实践(一)应用场景和安装
- vue中的侦听属性
- 折半查找
- 并查集-畅通工程 HDU 1232
- python challenge 7
- 运算符重载,友元函数;
- 堆排序 c++实现
- 是个胖子啊
- 116. Populating Next Right Pointers in Each Node
- 简易服务器
- 关于在hadoop上job运行的几种方式(不同平台)