BinarySearch(A, size, key) low = 0 high = size-1 found = false position = size while low ≤ high and not found mid = (low + high)/2 if A[mid] == key found = true position = mid if A[mid] < key low = mid+1 else high = mid-1 return position