Presentation on theme: "What else can we do with heaps? Use the heap for sorting. Heapsort!"— Presentation transcript:
What else can we do with heaps? Use the heap for sorting. Heapsort!
Basic Idea Given an unsorted array we use BuildHeap to convert it into a heap While(heap is not empty) –removeMin –The heap is one smaller but the array hasn't changed –Put the item just removed in the element just after the end of the heap At conclusion the array is sorted