Commit 66f4186c by BellCodeEditor

save project

parent d5afc004
Showing with 5 additions and 4 deletions
...@@ -9,12 +9,12 @@ def binary_search(alist,num): ...@@ -9,12 +9,12 @@ def binary_search(alist,num):
high=len(alist)-1 high=len(alist)-1
while low <= high: while low <= high:
mid = (low+high) // 2 mid = (low+high) // 2
num = alist[mid] guess = alist[mid]
if num == num: if guess == num:
return mid return mid
break break
elif num < num: elif guess < num:
low = mid+1 low = mid+1
elif num > num: elif guess > num:
high = mid-1 high = mid-1
print(binary_search(alist,1)) print(binary_search(alist,1))
\ 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