标签:
二分查找法一般指二分查找
public static int binarySearch(Integer[] srcArray, int des) { int low = 0; int high = srcArray.length - 1; while ((low <= high) && (low <= srcArray.length - 1) && (high <= srcArray.length - 1)) { int middle = low + ((high - low) >> 1); if (des == srcArray[middle]) { return middle; } else if (des < srcArray[middle]) { high = middle - 1; } else { low = middle + 1; } } return -1; }
标签:
原文地址:http://www.cnblogs.com/doubiqi/p/5024171.html