Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created March 20, 2021 08:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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