前言:
二分查找算法也称折半搜索算法,对数搜索算法,是一种在有序数组中查找某一特定元素的搜索算法。
形象图:
动图演示点击查看
循环实现:
/**
* while实现
* @param a
* @param fromIndex
* @param toIndex
* @param key
* @return
*/
private static int binarySearch0(long[] a, int fromIndex, int toIndex,
long key) {
int low = fromIndex;
int high = toIndex - 1;
while (low <=</