二分查找
头条面试题
"""
def bin_search(li, value , low, high):
if low<=high:
mid = (low+high) // 2
if li[mid] == value:
return mid
elif li[mid] > value:
return bin_search(li, value, low, mid-1)
else:
return bin_search(li, value, mid+1, high)
else:
return
li = [1,2,3,4,5,6,7,8,9]
index = bin_search(li, 3, 0, len(li)-1)
print(index)
"""