previous | index | next

Maximum Nodes

We can prove that nodes(h) = 2h+1-1 by using the following fact:

If h is not zero, the maximum number of nodes in a tree of height h is the maximum number of leaves in a tree of height h plus the maximum number of nodes in a tree of height h-1.

Formally,

nodes(h) = 1 if h = 0
= leaves(h) + nodes(h-1) if h > 0

This is known as a recurrence relation.


previous | index | next