标签:bin value arc 二分查找 arch ret search lse sea
def bin_search(data, value):
low = 0
hight = len(data) - 1
while low <= hight:
mid = (low+hight) // 2
if data[mid] == value:
return mid
elif data[mid] > value:
hight = mid - 1
else:
low = mid + 1
print(bin_search([2,1,8,3,6,9],6))
标签:bin value arc 二分查找 arch ret search lse sea
原文地址:https://www.cnblogs.com/qiaoqianshitou/p/9928340.html