Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : [30, 20, 15, 10] / [30, 20, 15, 10]

Advertisement

Detailed Solution

सही उत्तर [30, 20, 15, 10] / [30, 20, 15, 10] है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

One extract-max is performed on the max-heap [40, 30, 15, 10, 20]. The resulting array is: / मैक्स-हीप [40, 30, 15, 10, 20] पर एक एक्सट्रैक्ट-मैक्स किया जाता है। परिणामी ऐरे है:

1.
[30, 15, 20, 10] / [30, 15, 20, 10]
2.
[30, 20, 15, 10] / [30, 20, 15, 10]
3.
[20, 30, 15, 10] / [20, 30, 15, 10]
4.
[30, 20, 10, 15] / [30, 20, 10, 15]

Correct Answer: [30, 20, 15, 10] / [30, 20, 15, 10]

Remove 40 and move the last element 20 to the root → [20,30,15,10]; heapify down: 20 < 30, swap → [30,20,15,10]; 20 > 10, stop. / 40 हटाएँ और अंतिम तत्व 20 को मूल पर लाएँ → [20,30,15,10]; हीपिफाई डाउन: 20 < 30, अदला-बदली → [30,20,15,10]; 20 > 10, रुकें।

Downloaded from PrepSnap (prepsnap.in)