数据结构
CyrusMay
这个作者很懒,什么都没留下…
展开
-
prim算法
def prim(graph,n): state = [0 for i in range(n)] dist = [float("inf") for _ in range(n)] result = [] for i in range(n): if dist[0] == float("inf"): idx = 0 dist[0] = 0 else: mx = float(".原创 2021-09-27 11:55:08 · 98 阅读 · 0 评论 -
堆排序-Python
堆排序-Pythonpython代码 python代码 def build_heap(array): for i in range(len(array)//2-1,-1,-1): big_heap(array,i,len(array)) def big_heap(array,idx,n): l,r = 2*idx+1,2*idx+2 large = idx if l < n and array[large] < array[l]:原创 2021-09-25 13:06:47 · 135 阅读 · 0 评论