Question

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

Option 4 : 85 / 85

Advertisement

Detailed Solution

सही उत्तर 85 / 85 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

A max-heap is stored as the array [100, 90, 80, 30, 70]. After inserting 85, the element at index 2 is / एक अधिकतम-हीप (max-heap) ऐरे [100, 90, 80, 30, 70] के रूप में संग्रहीत है। 85 डालने के बाद, सूचकांक 2 पर तत्व है

1.
80 / 80
2.
90 / 90
3.
70 / 70
4.
85 / 85

Correct Answer: 85 / 85

85 is appended at index 5 whose parent at index 2 holds 80; since 85 is larger they swap, and 85 is smaller than the new parent 100, so the heap becomes [100, 90, 85, 30, 70, 80] with 85 at index 2. / 85 सूचकांक 5 पर जुड़ता है जिसका जनक सूचकांक 2 पर 80 रखता है; चूँकि 85 बड़ा है वे बदल जाते हैं, और 85 नए जनक 100 से छोटा है, अतः हीप [100, 90, 85, 30, 70, 80] बन जाती है जिसमें सूचकांक 2 पर 85 है।

Downloaded from PrepSnap (prepsnap.in)