Question
Which one of the following sequences when stored in an array at locations forms a max-heap?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2023 answer key
Solution
Verify the max-heap property and for each index .
For a 1-indexed array of length 10, internal nodes are :
- In Option (B):
- : and (Valid)
- : and (Valid)
- : and (Valid)
- : and (Valid)
- : (Valid)
All heap conditions are satisfied. In contrast, in Option (A), ; in (C), ; in (D), .
Final answer
Option (B)
Common trap
Checking only the immediate children of the root () rather than all internal nodes up to .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2023 Computer Science and Information Technology (CS)
- Question
- 12 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.