StreakPeaked· Practice

ExamsGATETechnical

The height of a binary tree is the maximum number of edges in any root-to-leaf path. The maximum number of nodes in a binary tree of height $h$ is:

  1. $2^h - 1$
  2. $2^{h-1} - 1$
  3. $2^{h+1} - 1$
  4. $2^{h+1}$

Correct answer: $2^{h+1} - 1$

Solution

A binary tree has at most 1 node at level 0, 2 at level 1, 4 at level 2, and so on. Summing from level 0 to level $h$ gives $1+2+4+\cdots+2^h = 2^{h+1}-1$.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →