📅  最后修改于: 2022-03-11 14:46:57.007000             🧑  作者: Mango
def binary_search(a, key):
low = 0
high = len(a) - 1
while low < high:
mid = (low + high) // 2
if key == a[mid]:
return True
elif key < mid:
high = mid - 1
else:
low = mid + 1
return False