Question
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height are:
Official answer and solution
- Official answer
- A
- From
- Official GATE 2015 answer key
Solution
Apply tree depth formulas to determine minimum and maximum nodes in a binary tree of height h.
Given that height is defined as the length of the longest root-to-leaf path (number of edges):
-
Minimum number of nodes:
Occurs in a degenerate binary tree where every internal node has exactly one child. The number of nodes on a path with 5 edges is: -
Maximum number of nodes:
Occurs in a complete, full binary tree where every level (from to ) is completely filled:
Therefore, the maximum and minimum numbers of nodes are and , respectively (option A).
A
Defining height as the number of nodes on the longest path instead of edges, which would give 31 and 5.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2015 Computer Science and Information Technology (CS) Session 1
- Question
- 35 of 65, printed as CS Q.25
- 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.