Stack & Catalan Number

String

Tree

For a tree of $N$ nodes and $n_d$ nodes of degree $d$, it holds that

$$N = \sum^{D}_{d=0}n_d=\sum^D_{d=0} n_d d+1 = E+1,$$

where $E$ is the number of edges and $D$ is the maximum degree of the tree. Then the number of leaves $n_0$ is given by

$$n_0 = 1 + \sum^D_{d=1} n_d(d-1),$$

and in a forest, the number of trees $T$ is given by

$$T = N - E.$$