In: Computer Science
Using the buildHeap method, write a sorting function that can sort a list in O(nlogn) time.
def buildHeap(self,alist): i = len(alist) // 2 self.currentSize = len(alist) self.heapList = [0] + alist[:] while (i > 0): self.percDown(i) i = i - 1
Base on this code please
Implementation of heapsort() method:
Test the heapsort() method in BinHeap class:
File: BinHeap.py
Sample Output: