ISRO 2013 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0154

In this question, a full binary tree is one in which every internal node has exactly two children and all leaves are at the same level (every level is completely filled). Which of the following numbers of nodes can form such a full binary tree?
  1. A
    8
  2. B
    15
  3. C
    14
  4. D
    13

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

Show the worked solution\[\boxed{\text{nodes in a full binary tree with } h \text{ levels} = 1+2+4+\cdots+2^{h-1} = 2^h-1}\]Possible sizes: 1, 3, 7, 15, 31, ...\(15 = 2^4-1\) (4 levels) works; 8, 14 and 13 are not of the form \(2^h-1\).(13 nodes can form a tree in which every node has 0 or 2 children, but not one with all leaves on the same level.)Answer: B

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