Uploaded by Devansh Alt

Q6

advertisement
Email: leanna.manuelpillai@torontomu.ca
QUESTION
4) A Heap data structure is initially empty; objects are added in order:
5, 4, 1, 8, 6
Show how the heap evolves as each item is added. (BUILD-HEAP and MAX-HEAPIFY)
(SHOW ALL STEPS) For each item added, indicate how many swap operations
are needed.
Three swaps are needed with a total of seven heaps constructed. The resulting Heap 7 can be considered
to be a Max Heap.
Download