Consider the following arrays of elements 289, 219, 250, 217, 212, 215, 22, 25, 27, 211, 26, 29, 300. What is the minimum number of interchanges needed to…
Consider the following arrays of elements 289, 219, 250, 217, 212, 215, 22, 25, 27, 211, 26, 29, 300. What is the minimum number of interchanges needed to convert it into max-heap?
Show answerHide answer
Correct answer: (D) 3
Explanation
Bottom-up heapify: 215 swaps with 300, 250 swaps with 300, then 289 swaps with 300. No other node violates the heap, so 3 interchanges.