new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 deletions
9
Task/Binary_search/Python/binary_search.py
Normal file
9
Task/Binary_search/Python/binary_search.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