Created
November 22, 2019 01:35
-
-
Save pruthvi6767/629c5f19ff4fc261d48890b9d18d1c93 to your computer and use it in GitHub Desktop.
bs
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
b = [1,2,3,4,5] | |
k = 6 | |
l = 0 | |
h = len(b) | |
def binary_Search(b,l,h,k): | |
m = (l+h)//2 | |
#print(m) | |
if b[m] == k: | |
return True | |
elif m < h-1 and b[m] < k: | |
return binary_Search(b,m,h,k) | |
elif l < m and b[m] > k: | |
print(b[m]) | |
return binary_Search(b,l,m,k) | |
else: | |
return False | |
print(binary_Search(b,l,h,k)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment