Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I want is to count the number of binary trees on $n$ nodes, except when a node has only one child, I don't distinguish between left and right. So let $T_n$ be the number of such trees on $n$ nodes, we have

\begin{align*} T_n=\left(\sum_{k=0}^{n-1}T_k\cdot T_{n-k-1}\right)-T_{n-1}. \end{align*}

I am not sure how to solve this recurrence. If we proceed the same way as in counting normal binary trees (where left and right matters when there's a single child) using generating function $g(s)=\sum_{n=0}^\infty T_ns^n$ and squaring it, I get that

\begin{align*} g(s)=\frac{1+s-\sqrt{1-2s-3s^2}}{2s}. \end{align*}

Calculating the series expansion around zero seems to give me what I want, but I cannot get this expression in the form of $\sum_nT_ns^n$ so the quantity $T_n$ comes out...

share|cite|improve this question
up vote 5 down vote accepted

This is A086246 in OEIS, but with the index shifted by $1$, and A001006, the Motzkin numbers, with the index shifted by $1$ in the other direction. (That is, $T_{n+1}=M_n$, where $M_n$ is the $n$-th Motzkin number.) The latter reference yields the possibly simpler recurrence


the asymptotic formula

$$T_n\sim 3^n\sqrt3\frac{1+\frac1{16n}}{(2n+3)\sqrt{(n+1)\pi}}\;,$$

and a wealth of references, formulas involving summations, and variant forms of the generating function, but there doesn’t seem to be a nice closed form.

Not so nice closed forms for the Motzkin numbers involving trinomial coefficients, hypergeometric functions, regularized hypergeometric functions and the gamma function, or Legendre polynomials can be found here.

share|cite|improve this answer

Your trees are described by an empty tree or a root linked to a sequence of at most 2 non-empty trees, in symbols: $$ \mathcal{T} = \mathcal{E} + \mathcal{Z} \times \mathfrak{S}_{\le 2}(\mathcal{T} - \mathcal{E}) $$ This directly gives the functional equation: $$ T(z) = 1 + z (1 + (T(z) - 1) + (T(z) - 1)^2) $$ This also gives: $$ T(z) = \frac{1 - z - \sqrt{1 - 2 z - 3 z^2}}{2 z} $$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.