Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 3 : 15
Advertisement
Detailed Solution
सही उत्तर 15 है।
Key Points
Helpful?
Question:
A max-priority queue is implemented as a binary max-heap. The keys 15, 10, 20, 8 are inserted, then extract-max is performed twice. What is the second value extracted? / max-प्राथमिकता कतार बाइनरी max-heap के रूप में कार्यान्वित है। कुंजियाँ 15, 10, 20, 8 डाली जाती हैं, फिर extract-max दो बार किया जाता है। दूसरी बार निकाला गया मान क्या है?
1.
20
2.
10
3.
15
4.
8
Correct Answer: 15
After the insertions the heap is [20, 10, 15, 8]. The first extract-max removes 20, leaving [15, 10, 8] after heapify. The second extract-max therefore returns 15. / निवेशन के बाद हीप [20, 10, 15, 8] है। पहला extract-max 20 हटाता है, heapify के बाद [15, 10, 8] बचता है। अतः दूसरा extract-max 15 लौटाता है।
Downloaded from PrepSnap (prepsnap.in)