Is there any formal definition about the average height of a binary tree?
I have a tutorial question about finding the average height of a binary tree using the following two methods:
The natural solution might be to take the average length of all possible paths from the root to a leaf, that is
$\qquad \displaystyle \operatorname{avh}_1(T) = \frac{1}{\text{# leaves in } T} \cdot \sum_{v \text{ leaf of } T} \operatorname{depth}(v)$.
Another option is to define it recursively, that is the average height for a node is the average over the average heights of the subtrees plus one, that is
$\qquad \displaystyle \operatorname{avh}_2(N(l,r)) = \frac{\operatorname{avh}_2(l) + \operatorname{avh}_2(r)}{2} + 1$
with $\operatorname{avh}_2(l) = 1$ for leafs $l$ and $\operatorname{avh}_2(\_) = 0$ for empty slots.
Based on my current understanding, for example the average height of the tree $T$
1
/ \
2 3
/
4
is $\operatorname{avh}_2(T) = 1.25$ by the second method, that is using recursion.
However, I still don't quite understand how to do the first one. $\operatorname{avh}_1(T) = (1+2)/2=1.5$ is not correct.