Catalan numbers
is the number of binary trees with nodes.
.
Balanced strings
Consider all strings of length over the alphabet that form balanced strings, i.e, the nesting of parenthesis is valid. For example, for , we have two: and . For , we have 5: , , , , . The number of such strings for is equal to .
A bijection between the set of all balanced strings of length and the set of all binary trees on vertices
Given a balanced string, treat the interior of the first matched pair of parenthesis as the left child, and what follows as the right child. For example, in , the left child is , and the right child is . It corresponds to this binary tree:
Here’s the bijection for :
Monotonic lattice paths which do not pass over the diagonal
If we replace ’(’ with ‘R’ and ’)’ with ‘U’, then a balanced string of length is a binary string with Rs and Us where each prefix has at least as many Rs as Us. If we now interpret the balanced string as a path in a grid starting form the origin, the set of all balanced strings will represent the set of all monotonic paths from to which do not cross the line. These are the 14 paths for :
This manifestation of the Catalan numbers leads naturally to an explicit formula for .
To compute the second term, notice that there exists a bijection between the set of all paths from to which rise above the line and the set of all paths from to :
Thus, we have
The recurrence relation
has a non-linear recurrence, which should be evident from the binary trees perspective. To make things work, we take .
Let the generating function be
Now,
The roots are .
Note that in all our pervious encounters with generating functions, we got a single solution. The solution with the minus does not work, since it is not possible to associate a formal power series with it (trust me bro).
So, working with the other solution, we get
(There is a truckload of justification that’s required for what we just did, but it’s ok to sweep it under the rug for now).
Finally, the Catalan numbers can be read off the coefficients: