Commit 5c75350c by BellCodeEditor

save project

parent 4b89ffaf
Showing with 9 additions and 3 deletions
...@@ -11,6 +11,12 @@ def binary_search(alist,num): ...@@ -11,6 +11,12 @@ def binary_search(alist,num):
high=len(alist) high=len(alist)
while low<=high: while low<=high:
mid=(low+high)//2 mid=(low+high)//2
guess=num_list[mid] guess=alist[mid]
if guess==num: if guess==num:
return mid
\ No newline at end of file elif guess<num:
low=mid+1
else:
high=mid-1
return None
print(binary_search(alist,num))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment