GATE CS 2006 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0213

A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. The roots is stored at X[1]. For a node stored at X[i], the left child, if any, is stored in X[2i] and the right child, if any, in X[2i + 1]. To be able to store any binary tree on n vertices, the minimum size of X should be
  1. A
    log n
  2. B
    n
  3. C
    2n+1
  4. D
    \(2^{n}-1\)

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option D.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/974/gate2006-13

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com