Question
Let be a binary search tree with 15 nodes. The minimum and maximum possible heights of are:
Note: The height of a tree with a single node is 0.
Official answer and solution
- Official answer
- B
- From
- Official GATE 2017 answer key
Solution
Determine the minimum height using a complete binary tree structure and the maximum height using a degenerate chain structure for 15 nodes.
The height of a single-node tree is defined as 0. For a binary tree with nodes:
- The maximum possible height occurs when the tree is degenerate (skewed), where every internal node has exactly one child. In this linked-list structure, a tree with nodes has edges from the root to the leaf:
- The minimum possible height occurs when the tree is as balanced as possible (a complete binary tree). A perfect binary tree of height contains nodes. For :
Therefore, the minimum and maximum possible heights of are 3 and 14 respectively.
B
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 1
- Question
- 6 of 65, printed as CS Q.6
- 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.