摘要: class HashTable: def __init__(self, size): self.elem = [None for i in range(size)] self.count = size # def hash(self, key): return key % self.count # def ... 阅读全文
posted @ 2018-09-22 00:20 anobscureretreat 阅读(190) 评论(0) 推荐(0)
摘要: class BSTNode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right class BinarySortTree: def __init__(self... 阅读全文
posted @ 2018-09-22 00:18 anobscureretreat 阅读(947) 评论(0) 推荐(0)
摘要: def fibonacci_search(lis, key): # F = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368] low = 0 hi... 阅读全文
posted @ 2018-09-22 00:14 anobscureretreat 阅读(184) 评论(0) 推荐(0)
摘要: def binary_search(lis, key): low = 0 high = len(lis) - 1 time = 0 while low lis[mid]: low = mid + 1 else: # print("times: %s" % time) ... 阅读全文
posted @ 2018-09-22 00:12 anobscureretreat 阅读(272) 评论(0) 推荐(0)
摘要: def binary_search(lis, key): low = 0 high = len(lis) - 1 time = 0 while low lis[mid]: low = mid + 1 else: # print("times: %s" % time) ... 阅读全文
posted @ 2018-09-22 00:10 anobscureretreat 阅读(99) 评论(0) 推荐(0)
摘要: def sequential_search(lis, key): for i in range(len(lis)): if(lis[i] == key): return i else: return False LIST = [1, 5, 8, 123, 22, 54, 7, 99, 300, 222... 阅读全文
posted @ 2018-09-22 00:08 anobscureretreat 阅读(256) 评论(0) 推荐(0)
摘要: def merge_sort(array): def merge_arr(arr_l, arr_r): array = [] while len(arr_l) and len(arr_r): if arr_l[0] arr_r[0]: array.append(arr_r.pop(0)) ... 阅读全文
posted @ 2018-09-22 00:01 anobscureretreat 阅读(179) 评论(0) 推荐(0)