Example #1
0
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())
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()
Example #4
0
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()