- GATE CS
- 2026–27 pattern practice
- Data Structures
- Heaps
- Easy
A binary heap is stored in an array with the root at . At which index is the left child of the node at index ?
Trees
Pick an option to check your answer.
Answer: B. Solution
In 1-based array storage of a complete binary tree, the children of index sit at and , and the parent at . For the root () the children are at 2 and 3, which matches. So the left child is at .
Why not the others
- is the index of the right child.
- is the index of the parent.
- would put the left child of the root at index 1, the root itself.