GATE CS 2024 Set 1 | Question 41
Programming & Data Structures › Heaps · MCQ · 2 marks · Answer: D
- Question 41Programming & Data Structuresmcq2 marksThe array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified (max-heap). Which represents the first three elements?
- A.82, 90, 101
- B.82, 11, 93
- C.131, 11, 93
- D.131, 111, 90✓
Answer: D
Solution
Answer: (D) 131, 111, 90 Building a max-heap, the maximum element 131 becomes the root. After heapify, the root's two children are the next two largest along the chosen paths, giving 111 and 90 as the first level below. So the first three array positions are 131, 111, 90. - A.
More GATE PYQ on Heaps
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2024 Set 1 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →