Question: 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 =
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
