def bisearch(elems, key): low = 0 high = len(elems) - 1 while low <= high: mid = (low + high)//2 if key == elems[mid].key: return elems[mid].value if key < elems[mid].key: high = mid - 1 else: low = mid + 1
本文共 373 字,大约阅读时间需要 1 分钟。
def bisearch(elems, key): low = 0 high = len(elems) - 1 while low <= high: mid = (low + high)//2 if key == elems[mid].key: return elems[mid].value if key < elems[mid].key: high = mid - 1 else: low = mid + 1
转载于:https://www.cnblogs.com/theodoric008/p/8037128.html