-
-
Save amankharwal/0e7e0cd12f038d76fe59539ed2af0e8c 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 rec_binarySearch(target, sequence, first, last): | |
if first > last: | |
return False | |
else: | |
mid = (last + first) // 2 | |
if sequence[mid] == target: | |
return True | |
elif target < sequence[mid]: | |
return rec_binarySearch(target, sequence, first, mid-1) | |
else: | |
return rec_binarySearch(target, sequence, mid + 1, last) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment