Question

Let TT be a binary search tree with 15 nodes. The minimum and maximum possible heights of TT are:

Note: The height of a tree with a single node is 0.

Choose one option
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 nn 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 nn nodes has n−1n - 1 edges from the root to the leaf:
hmax⁡=n−1=15−1=14h_{\max} = n - 1 = 15 - 1 = 14
  • The minimum possible height occurs when the tree is as balanced as possible (a complete binary tree). A perfect binary tree of height hh contains 2h+1−12^{h+1} - 1 nodes. For n=15n = 15:
2h+1−1=15  ⟹  2h+1=16  ⟹  h+1=4  ⟹  hmin⁡=32^{h+1} - 1 = 15 \implies 2^{h+1} = 16 \implies h + 1 = 4 \implies h_{\min} = 3

Therefore, the minimum and maximum possible heights of TT are 3 and 14 respectively.

Final answer

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.