def binary_search(data, target, low, high): #适用于从小到大顺序排列的数据
if low>high:
return False
else:
mid = (low+high)//2
if data[mid] > target:
return binary_search(data, target, low, mid-1)
elif data[mid] < target:
return binary_search(data, target, mid+1,high)
else:
return True
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)