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 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
Get step-by-step solutions from verified subject matter experts
