摘要:
def heap_sort(elems): """堆排序""" def siftdown(elems, e, begin, end): i, j = begin, begin * 2 + 1 while j < end: if j + 1 < end and elems[j + 1] < elems 阅读全文
摘要:
连续表实现优先队列: """基于list实现优先队列""" class PrioQueueError(ValueError): pass class PrioQueue: """ 数据的存储位置按优先顺序排列 值较小的元素优先级更高 """ def __init__(self, elist=[]): 阅读全文