二分查询算法
def binarysearch(a, target):
low = 0
high = len(a) – 1
while low > 1,java中是int mid = (low + high) >>> 1。
mid = (low + high) // 2
midval = a[mid]
if midval < target:
low = mid + 1
elif midval > target:
high = mid – 1
else:
return mid
return -1