GATE CS 2023 | Question 12
Programming & Data Structures › Heaps · MCQ · 1 mark · Answer: B
- Question 12Programming & Data Structuresmcq1 markWhich sequence stored at forms a max-heap?
- A.23, 17, 10, 6, 13, 14, 1, 5, 7, 12
- B.23, 17, 14, 7, 13, 10, 1, 5, 6, 12✓
- C.23, 17, 14, 6, 13, 10, 1, 5, 7, 15
- D.23, 14, 17, 1, 10, 13, 16, 12, 7, 5
Answer: B
Solution
Answer: (B) 23, 17, 14, 7, 13, 10, 1, 5, 6, 12 A max-heap requires and . Checking (B):
all hold. In (A) 13<14 (A[5]<A[6])? ok, but fails. (C) fails. (D) ? root ok but ... fails. Only (B) is a valid max-heap.23>=17,14 | 17>=7,13 | 14>=10,1 | 7>=5,6 | 13>=12 - A.
More GATE PYQ on Heaps
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2023 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →