# Relationship between height and depth of a binary tree

The wikipedia says that the number of nodes n in a full binary tree, is at least $n=2^h-1$ and at most $n=2^{h+1}-1$, where h is the height of the tree.

The following binary tree is full according to the wikipedia definition (every node has 0 or 2 children), n = 11, h = 4 but n is not greater than $2^4 - 1 = 15$.

Am I missing something?

                        .
/  \
a    .
/ \
b   .
/ \
.   .
/ \ / \
c  d e  f

• Ahhh, the joys of Wikipedia... – Raphael Sep 15 '16 at 17:22

You're not missing anything: it's a typo, which I've fixed. The page gives two separate definitions of "full binary tree" (a recursive one and the one you quote) and both of them include the following trees, which have even fewer nodes than yours ($2n-1$, to be precise):

  o
/ \
o   o
/ \
o   .
.
.
\
o
/ \
o   o

• this inductive proof math.stackexchange.com/a/220433/60114 seems to be ok and he proves that the minimum number of nodes is $2h + 1$ not $2h -1$. How did you arrive at that formula? – dmz73 Sep 16 '16 at 9:03
• @dmz73 I took the height to be the number of vertices on the longest path from leaf to root; the other answer probably took it to be the number of edges. – David Richerby Sep 16 '16 at 9:31
• Since you edited wikipedia I think it would be better to consider depth as the number of edges, so that root is at level 0. This is the most common definition. – dmz73 Sep 16 '16 at 23:52
• @dmz73 "Wikipedia: the encyclopedia anyone can edit" (emphasis mine). – David Richerby Sep 17 '16 at 11:35

If you think about how you get these bounds¹ it's quite clear that they apply to complete binary trees, using terms from the article.

To be fair, the terminology around binary trees is ambiguous, overloaded, and inconsistent in the literature. It becomes worse if you use multiple languages. Hence, it comes to no surprise that a crowd-edited medium without real quality control such as Wikipedia would have errors.

1. Hint: $\sum 2^i$
• Appropriately, the Wikipedia article even says that terminology is inconsistent. – David Richerby Sep 15 '16 at 17:28