Created
April 25, 2020 06:27
-
-
Save computer-tutor/03abf036452eb6d570a2742ca8acb77c 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 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