Question: Option 2 (Bottom-up) procedure build Heap(int[] a) Put the elements of a into a complete binary tree (in any order) // Each leaf is

Option 2 (Bottom-up) procedure build Heap(int[] a) Put the elements of a

Option 2 (Bottom-up) procedure build Heap(int[] a) Put the elements of a into a complete binary tree (in any order) // Each leaf is a subtree with the max-heap property do the lowest, rightmost node in the ptr tree whose children are known to be heaps sinkDown(ptr) // Now ptr's subtree is a max heap while ptr #root The above has a O(n) run time!!! Key facts: 2k 1. 2. 2k Do a trace, draw the pictures. The array representation makes the above very easy. See:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!