Binary Search Algorithm

Just a BS(bulls**t) algorithm, nothing special

int binaryS (int[] array, int key, int min, int max) {
    if (max < min) {
        return -1;//can’t find
    }
    int mid = (min + max) / 2;
    if (array[mid] > key) {
        return binaryS(array, key, min, mid-1);
    } else if (array[mid] < key) {
        return binaryS(array,key, mid+1, max);
    } else {
        return mid;
    }
}
posted on 2015-03-31 15:09  Seth_L  阅读(116)  评论(0编辑  收藏  举报