2013年5月5日

二分搜索

摘要: 1 from math import ceil, floor 2 3 def b_search(source, target): 4 max = len(source) 5 mid = max/2 6 if target>source[int(mid)]: 7 mid = ceil(mid) 8 else: 9 mid = floor(mid)10 target_sub = mid;11 12 if source[mid]>target:13 target_sub = b_search(sour... 阅读全文

posted @ 2013-05-05 16:34 mtima 阅读(163) 评论(0) 推荐(0)

导航