- #1

SpatialVacancy

- 24

- 0

Code:

```
def binarySearch(inputArray, match):
x = -1
start = 0
end = len(inputArray) - 1
while not start == end:
midPt = (start + end) / 2
if match < inputArray[midPt]:
end = midPt - 1
elif match > inputArray[midPt]:
start = midPt + 1
else:
return midPt
if inputArray[start] == match:
x = start
return x
```

The code is Python, but I figure anyone can read it without much explination. I have to prove that this algorithm works. I don't know how to do this! Any help would be appreciated!

Thanks