Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Binary-search/Python/binary-search-3.py
Normal file
10
Task/Binary-search/Python/binary-search-3.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def binary_search(l, value, low = 0, high = -1):
|
||||
if not l: return -1
|
||||
if(high == -1): high = len(l)-1
|
||||
if low >= high:
|
||||
if l[low] == value: return low
|
||||
else: return -1
|
||||
mid = (low+high)//2
|
||||
if l[mid] > value: return binary_search(l, value, low, mid-1)
|
||||
elif l[mid] < value: return binary_search(l, value, mid+1, high)
|
||||
else: return mid
|
||||
Loading…
Add table
Add a link
Reference in a new issue