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)
浙公网安备 33010602011771号