def heapsort(alist): bin = BinHeap() bin.buildheap(alist) print('builtlist') res = [] for i in range(len(alist)): # print(bin.delmin()) # print(bin.heaplist) res.append(bin.delmin())
class PQueue: def __init__(self, alist): self.heap = BinHeap() self.heap.buildheap(alist) def enqueue(self, p, item): self.heap.insert(Item(p, item)) def dequeue(self): return self.heap.delmin()