The minimum is removed from the min-heap by moving the last element to the root and sifting it down. What is the resulting array?
Correct answer B. [3, 4, 7, 10, 8]
Explanation
Remove 1 and move the last element, 7, to the root: [7, 4, 3, 10, 8]. Sift down by swapping with the smaller child: 3 is smaller than 4, so swap to get [3, 4, 7, 10, 8]. At index 2, 7 has no children, so it stops. Swapping with the larger child would break the heap property.
Answer checked How we write and check questions
Discussion