摘要:
原文在:http://www.zhuoda.org/weiking/67932.html一个经典的二分查找算法1: public static int binarySearch(int[] a, int key) {2: int low = 0;3: int high = a.length - 1;4: 5: while (low key)12: high = mid - 1;13: else14: return mid; // key found15: }16: return -(low + 1);// key not found.17: }很有意思,java.util.Arrays的BU. 阅读全文