Why does a complete binary tree of $n$ leaves have $2n-1$ nodes?

Any full binary tree can be seen as the structure of a single elimination tournament with $n$ teams corresponding to the leaves. Each non-leaf is a game in which the loser goes home and the winner goes up to the next round. There is one final champion, who wins the root game, and so there must be $(n-1)$ non-leaf nodes since every other team loses exactly once. Hence $n + (n-1) = 2n-1$ nodes altogether.


A perfect (complete and full) binary tree always has $2^m$ leaves for some $m$. Now how many nodes will it have? Well, it will have $1$ root, and $2$ children of the root, and $4$ total children of those children, and so on, up to and including the $2^m$ leaves. So there will be $$ 1 + 2 + 4 + 8 + \cdots + 2^m = \sum_{i = 0}^m 2^i $$ total nodes in a perfect binary tree with $2^m$ leaves. Now there is a standard formula that $$ \sum_{i = 0}^m 2^i = 2^{m+1} - 1. $$ If we start by saying that $n = 2^m$ is the number of leaves then $2^{m+1} -1$ nodes is the same as $2\cdot 2^m - 1 = 2n - 1$ nodes, which is the formula requested in the question.


Well start off with the parent node. If you only have one node, that's one leaf, and $2(1) - 1 = 1$. This equation implies that every time you add another leaf, then the total number of nodes will increase by 2.

Now adding two children means taking away one leaf (the parent used to be a leaf) and adding two new leaves, which gives a total of one new leaf. You are adding two nodes from one extra leaf, so it turns out this equation works out.

Tags:

Graph Theory