python 二分法查找

2021-06-20 08:03

阅读:563

标签:%s   search   div   mes   lse   highlight   arc   arch   htm   

def binary_search(lis, key):
    low = 0
    high = len(lis) - 1
    time = 0
    while low  lis[mid]:
            low = mid + 1
        else:
            # 
            print("times: %s" % time)
            return mid
    print("times: %s" % time)
    return False
 

LIST = [1, 5, 7, 8, 22, 54, 99, 123, 200, 222, 444]
result = binary_search(LIST, 99)
print(result)

  

python 二分法查找

标签:%s   search   div   mes   lse   highlight   arc   arch   htm   

原文地址:https://www.cnblogs.com/sea-stream/p/9689109.html


评论


亲,登录后才可以留言!