I have to come up with an algorithm to search a sorted array. Here it is:(adsbygoogle = window.adsbygoogle || []).push({});

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!!Code (Text):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

Thanks

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Prove an Algorithm

**Physics Forums | Science Articles, Homework Help, Discussion**