Python实现二分查找(二分查询)
程序员文章站
2022-05-14 13:47:49
...
二分查询算法
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: high = mid - 1 else: return mid return -1