-
-
Save amankharwal/265d0b6f5f6b4f267770724bfb3d88ba 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