new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
9
Task/Binary-search/Python/binary-search-1.py
Normal file
9
Task/Binary-search/Python/binary-search-1.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def binary_search(l, value):
|
||||
low = 0
|
||||
high = len(l)-1
|
||||
while low <= high:
|
||||
mid = (low+high)//2
|
||||
if l[mid] > value: high = mid-1
|
||||
elif l[mid] < value: low = mid+1
|
||||
else: return mid
|
||||
return -1
|
||||
Loading…
Add table
Add a link
Reference in a new issue