# low and high have to be integers
def binarySearch(array, key, low, high):
if low > high: # termination case
return -1
middle = (low + high) / 2 # gets the middle of the array
if array[middle] == key: # if the middle is our key
return middle
elif key < array[middle]: # our key might be in the left sub-array
return binarySearch(array, key, low, middle-1)
else: # our key might be in the right sub-array
return binarySearch(array, key, middle+1, high)
#//python/4538