BetterManEddy

导航

 
data_set = list(range(100))
#print(data_set)
def b_search(n,low,high,d):
    mid = int((low + high)/2)
    if low == high:
        print("not found")
        return
    if d[mid] > n:
        print("please turn left:\n",low,high,d[mid])
        b_search(n,low,mid,d)
    elif d[mid] < n:
        print("please turn right:\n",low,high,d[mid])
        b_search(n,mid+1,high,d)
    else:
        print("find it\n",d[mid])
b_search(89,0,len(data_set),data_set)

 

 

posted on 2020-04-15 12:25  BetterManEddy  阅读(56)  评论(0)    收藏  举报