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.
GATE CSE 2017Data Structures › Trees & Binary Search TreesVerified
(B) 3 3 3 and 14 14 14 respectively.
The height of a BST depends only on its shape, not on the ordering property (any binary-tree shape can be realized as a BST by assigning keys in the correct order). So the question reduces to: over all binary trees with $n = 15$ nodes, what are the largest and smallest possible heights, where height is counted in edges (single node $\Rightarrow h = 0$)? The tallest shape is the fully skewed chain; the shortest shape is the balanced/complete tree.
For $n = 15$ nodes with height measured in edges, the shortest BST is complete and needs $\lceil \log_2(n+1) \rceil - 1 = 3$ levels of edges, while the tallest is a skewed chain of height $n - 1 = 14$. Therefore the minimum and maximum heights are 3 and 14, i.e. option B.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.