Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def adm_search(arr, x, f=0, l=10):
if l >= f:
mid = (f+l)//2
if arr[mid] == x: # Found
return mid
elif arr[mid] > x:
return adm_search(arr, x, f, mid-1) # search below
else:
return adm_search(arr, x, mid+1, l) # search above
else:
return 'Not Found'
# adm list can be of any number
adm = [456, 467, 489, 500, 546, 567, 588, 599, 600, 612, 613]
print(adm_search(adm, 234))
print(adm_search(adm, 500))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment