in DS edited by
16,628 views
33 votes
33 votes

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

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

  1. $4$ and $15$ respectively.
  2. $3$ and $14$ respectively.
  3. $4$ and $14$ respectively.
  4. $3$ and $15$ respectively.
in DS edited by
by
16.6k views

10 Answers

22 votes
22 votes
Best answer

The maximum height of a binary search tree will be when the tree is fully skewed

Maximum height  $= n - 1 = 15 – 1 = 14$

The minimum height of a binary search tree will be when the tree is full.

Minimum height  $= \log_2( n + 1 ) – 1 =  \log_2( 15 + 1 ) – 1 = \log_2( 16 ) – 1 = 4 - 1 = 3$

Correct Answer: $B$

edited by

4 Comments

min ht. should  be floor[logn] right?

because for 14 nodes the min ht of tree is also 3 ,which we can get by floor[logn]

but not by log(n+1)-1.

1
1

@Pranavpurkar

Max nodes for height ‘h’ $ (n) = 2^{h+1} -1$

Hence, Min Height = $ log(n+1) – 1$

2
2

then  it must be ceil of that value for minimum height.

1
1

Yes @Pranavpurkar, it will be $\lceil(log(n+1))\rceil$

1
1
27 votes
27 votes

Min height of a binary tree is given by $\log _{2}(n+1)-1=4-1=3$

max height of the binary tree is $n - 1$ (skewed binary tree$= 15 - 1 =14$

Ans:B) $3,14$

edited by
13 votes
13 votes
B) 3,14 .

Worst case : skewed
12 votes
12 votes

please do correct me if I m wrong

by
Answer:

Related questions