Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 25, 2020 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save computer-tutor/03abf036452eb6d570a2742ca8acb77c to your computer and use it in GitHub Desktop.
Save computer-tutor/03abf036452eb6d570a2742ca8acb77c to your computer and use it in GitHub Desktop.
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