previous | index | next

Maximum Nodes

Consider the second part:

nodes(h) = leaves(h) + nodes(h-1)
= 2h + nodes(h-1)
= 2h + 2h-1 + nodes(h-2)
= 2h + 2h-1 + 2h-2 + ... + 4 + 2 + 1

Now rewrite nodes(h) as (2 x nodes(h)) - nodes(h):

2 x nodes(h) = 2h+1 + 2h + 2h-1 + 2h-2 + ... + 4 + 2
− nodes(h) = 2h − 2h-1 − 2h-2 − ... − 4 − 2 − 1




nodes(h) = 2h+1 − 1

Exercise 8.10: Prove that nodes(h) = 2h+1 − 1 by induction on h.


previous | index | next