• edited by
3,756 views
8 8 votes
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with $23$ nodes is $\_\_\_\_$.(answer in integer)

5 Answers

8 8 votes

we know that for  any binary tree:

total number of nodes $n$= internal nodes $(I)$+ leaf node $( L)$

In a Full Binary Tree, the number of leaves is always one more than the internal nodes:$L=I+1$

Substitute $L$ into the total nodes equation: 

$n = I + (I + 1) = 2I + 1$

now put $n = 23$: 

$23 = 2I + 1 \implies 22 = 2I \implies I = 11$.

To get the maximum height, we should arrange these$11$ internal nodes in a single path (skew tree). Each internal node then contributes exactly 1 edge to the height.Therefore, Max Height = Number of Internal Nodes = 11.

• moved by
6 6 votes

Full binary tree : Every node has either 0 or 2 children.

 

Asked for max height for 23 nodes.

 

In exam i drawn this and made the answer without any formula, ofcourse in less than 1 min hope this helps to build your intuition.

(start first node with count 1, just count the skewed lines it will be 11.)

• moved by
4 4 votes

A full binary tree is a binary tree with either zero or two child nodes for each node.

Remove the root and then the problem boils down to make groups of $2$ with $n-1$ elemets, which will be  $\frac{(n-1)}{2}$.

So ans will be $11$.

I don't know why in the exam I thought full BT = complete BT and answered $4$:)

• moved by
0 0 votes

For a full binary tree:

  • Every node has either 0 or 2 children
  • Maximum height occurs when the tree is as “skewed” as possible while still remaining full.

 

A full binary tree with height h has:

Minimum nodes = 2h+1

(because each internal node contributes exactly one extra leaf)

 

Given:

                         2h+1=23

                         2h=22 

                         h=11

So the maximum possible height is:

11

 

Answer:
Position:
Show:

Related questions

62 62 votes
5 answers 5 answers
25.5k
25.5k views
Arjun asked Feb 12, 2020
25,487 views
Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
21 21 votes
3 3 answers
3.6k
3.6k views
gatecse asked Feb 23
3,600 views
Consider the recursive functions represented by the following code segment:int bar(int n) { if (n == 1) return 0; else return 1 + bar(n/2); } int foo(int n) { if (n == 1)...
5 5 votes
3 3 answers
2.0k
2.0k views
gatecse asked Feb 23
2,009 views
The following sequence corresponds to the preorder traversal of a binary search tree $T$ :\[50,25,13,40,30,47,75,60,70,80,77\]The position of the element $60$ in the post...
14 14 votes
7 7 answers
2.6k
2.6k views
gatecse asked Feb 23
2,621 views
Consider the following recurrence relations:For all $n>1$,\[\begin{array}{c}T_{1}(n)=4 T_{1}\left(\frac{n}{2}\right)+T_{2}(n) \\T_{2}(n)=5 T_{2}\left(\frac{n}{4}\right)+\...