Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Data Structures
  • Heaps
  • Easy

A binary heap is stored in an array A[1..n]A[1..n] with the root at A[1]A[1]. At which index is the left child of the node at index ii?

Trees

Pick an option to check your answer.

In 1-based array storage of a complete binary tree, the children of index ii sit at 2i2i and 2i+12i + 1, and the parent at ⌊i/2⌋\lfloor i/2 \rfloor. For the root (i=1i = 1) the children are at 2 and 3, which matches. So the left child is at 2i2i.

Why not the others

  • 2i+12i + 1 is the index of the right child.
  • ⌊i/2⌋\lfloor i/2 \rfloor is the index of the parent.
  • 2i−12i - 1 would put the left child of the root at index 1, the root itself.

Report an error

GATE CS · Data Structures · Trees