Lab 9 - Heapsort

Due: 5:00pm on Wednesday

The purpose of this lab is to trace through the process of using heapsort on paper. There is no coding for this lab.

Show how you would heapify then heapsort the following array: 17, 33, 3, 22, 45, 96, 42, 54, 15, 9

Show all steps. Work that does not show all steps will not get full credit.

For heapify, show where you would start testing for the heap property (e.g. where you would start the "percolate down" routine) by circling or bolding the node. Then show how percolate down restores the heap property for that node. Show each swap needed in percolate down until the heap property is restored. Repeat this process with the next node, until you work your way back to the root. Either draw the heap or use the array representation of the heap to show how the heap is altered at each step.

For heapsort, show the process of deleting each root node. Show each step of the deletion process: swapping the last element up to the root and the "percolate down" routine for that element. Again, either draw the heap or use the array representation of the heap to show how the heap is altered at each step and show each swap involved in the "percolate down" process. Repeat the deletion process until all nodes are deleted off the heap.

Turn in either a hand-written or electronic writeup.