Created
March 2, 2017 22:10
-
-
Save juanitobanca/842d5b07821b6ebd789d7098df36b4e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binarySearch( alist, anum ): | |
low = 0 | |
high = len(alist)-1 | |
while low <= high: | |
mid = (low + high)/2 | |
if alist[mid] == anum: | |
return True | |
if alist[mid] < anum: | |
low = mid + 1 | |
else: | |
high = mid -1 | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment