Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created May 15, 2021 17:33
Show Gist options
  • Save Park-Developer/d5435f90d1e783f2c750f966a2fe4883 to your computer and use it in GitHub Desktop.
Save Park-Developer/d5435f90d1e783f2c750f966a2fe4883 to your computer and use it in GitHub Desktop.
binary search using iteration
# 반복문
def binary_search_iter(seq, target):
high , low=len(seq),0
while low < high:
mid = (high+low)//2
if target ==seq[mid]:
return mid
elif target<seq[mid]:
high=mid
else:
low=mid+1
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment