Algorithm
# Input: Sorted Array A, integer key
# Output: first index of key in A, or -1 if not found
Algorithm: Binary_Search (A, left, right)
while left <= right
middle = index halfway between left, right
if D[middle] matches key
return middle
else if key less than A[middle]
right = middle -1
else
left = middle + 1
return -1