标签:else bin 算法基础 python 查找 nbsp min find search
def binary_search(data_source,find_n):
mind=int(len(data_source)/2)
if len(data_source)>=1:
if data_source[mid]>find_n:
print("data in left of [%s]"%sdata_souerce[mid])
//print(data_souerce[:mid]
binary_search(data_source[:mid],find_n)
elif data_source[mid]<find_n:
print("data in right of [%s]"%data_souerce[mid])
//print(data_souerce[mid:]
binary_search(data_source[mid:],find_n)
else:
print("found find_s "data_souerce[mid])
binary_search(data_source[mid:],find_n)
else:
print("cannot find....")
if_name_==‘_main_‘:
data=list(range(1,600,3)
print(data)
binary_search(data,39)
标签:else bin 算法基础 python 查找 nbsp min find search
原文地址:http://www.cnblogs.com/my334420/p/6400440.html