用python实现二分查找

    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
posted @ 2017-12-14 12:57  一条图图犬  阅读(220)  评论(0编辑  收藏  举报