Question: Why do we want the loop index i in line 2 of BUILD-MAX-HEAP to decrease from A.length/2 to 1 rather than increase from 1 to
Why do we want the loop index i in line 2 of BUILD-MAX-HEAP to decrease from ⌊A.length/2⌋ to 1 rather than increase from 1 to ⌊A.length/2⌋?
Step by Step Solution
3.35 Rating (161 Votes )
There are 3 Steps involved in it
In max heap we want the largest element to be at index 1 so if we start t... View full answer
Get step-by-step solutions from verified subject matter experts
