递归二分查找

    private int recursiveBinarySearch(int left,int right,int target,int[] list){
        if (list == null || target > list[right] || target < list[left] || left > right)
            return -1;
        int mid = (left + right) / 2;
        if(list[mid] == target) {
            return mid;
        }else if(list[mid] > target) {
            return recursiveBinarySearch(left,mid,target,list);
        }else {
            return recursiveBinarySearch(mid,right,target,list);
        }
    }

你可能感兴趣的:(递归二分查找)