The array is turned into a max-heap using the bottom-up build-heap method, sifting down from the last internal node to the root. What is the resulting array?
Correct answer C. [9, 4, 5, 1, 3, 2]
Explanation
Start at index 2 (value 2): its child 5 is larger, so swap to get [3, 9, 5, 1, 4, 2]. Index 1 (value 9) is larger than 1 and 4, so it stays. At the root, 3 swaps with 9, then 3 swaps with its larger child 4, giving [9, 4, 5, 1, 3, 2]. The fully sorted descending array is a valid heap but not what the algorithm produces.
Answer checked How we write and check questions
Discussion