Site Search:

maze quiz 8

public static int rank(int[] a, int key) {
    int lo = 0;
    int hi = a.length - 1;
    while(lo <= hi) {
        //what is missing here?
        if(key < a[mid]) hi = mid - 1;
        else if(key > a[mid] lo = mid + 1;
        else return mid;
    }
    return lo;
}