Skip to content

Instantly share code, notes, and snippets.

@pruthvi6767
Created November 22, 2019 01:35
Show Gist options
  • Save pruthvi6767/629c5f19ff4fc261d48890b9d18d1c93 to your computer and use it in GitHub Desktop.
Save pruthvi6767/629c5f19ff4fc261d48890b9d18d1c93 to your computer and use it in GitHub Desktop.
bs
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