二分查找
摘要:
static boolean binarySearch(int target, int[] array) {17 int front = 0;18 int tail = array.length - 1;19 // 判断子数组是否能再次二分20 while (front <= tail) {21 // 获取子数组的中间位置,并依据此中间位置进行二分22 int middle = (front + tail) / 2;2324 if (array[middle] == target) {25 return true;26 } else if (array[middle] > targ 阅读全文
posted @ 2012-09-07 18:04 追寻的梦 阅读(80) 评论(0) 推荐(0)
浙公网安备 33010602011771号