CSc 150
Some Hints

  1. As we've seen many times with recursion, a public method often calls a private method that does the actual recursive work. For binary search, the "make the problem smaller" part of the recursive case involves looking at just a subsection of the array. You can make this happen with this private method:

    private int binSearch(int[] A, int key, int left, int right)
    

    with the extra two parameters being the leftmost and rightmost indicies of the array. Thus, assuming the int myKey is the key, one would call this method from the public method like this:

    binSearch(A, myKey, 0, A.length-1);