This document aims to give the reader an introduction to Catalan numbers, a sequence of numbers arising throughout mathematics. Catalan number appears frequently in computer science and combinatorics counting problems.
Catalan number is the solution to -
- number of Binary Trees with n unlabelled vertices,
- number of Full Binary Trees with n+1 leaves (or 2n +1 vertices),
- number of possible Binary Search Trees (BSTs) with n distinct keys,
- number of stack-sortable permutations,
- number of ways to form a Balanced parentheses sequences with n pairs,
- number of paths on an n X n grid that stay below or touch the main diagonal,
- number of non-nesting and non-crossing matchings of 2n vertices,
- number of noncrossing handshakes possible across a round table between n pairs of people, and over 200 more different objects that can be counted by catalan number.
$$C_{n} = \frac{1}{n+1} \binom{2n}{n} = \frac{1}{n} \binom{2n}{n-1} = \frac{(2n)!}{(n+1)! n!} = \binom{2n}{n} - \binom{2n}{n-1}$$
How do you prove that two counting problems have the same answer? The bijection principle tells us that if there is a bijection between two sets, then the sets have the same size. So let's find some bijections.
Below are proofs and interesting observations meant only for analysis-loving enthusiasts. I will start with basics and go as far as I know.
(0.1 and 0.2 are sort of prequel and from 1 onwards are some of the various families of mathematical objects that are counted by catalan numbers.)
0.1] Suppose you can only move unit-length east (E) amd unit-length north (N). A lattice path is a sequence of east (E) and north (N) steps starting at (0,0) and ending at (n,n) in a n x n grid.
Lemma: For any m and n, there are$\binom{m+n}{n}$ lattice paths from (0, 0) to (m, n) in the m × n grid.
Proof. Think of a lattice path as a sequence of letters indicating the steps, N for north and E for east. To reach (m, n), a lattice path must have exactly m E’s and n N’s, but can have them in any order.
Now think of a line of [m + n] empty boxes. In each box we can place either an E or an N. E in box i means “put i in the subset” and N in box i meaning “throw away i”.
e.g. ENENNENE of 4X4 grid corresponds to the subset { 1, 3, 6, 8 } of [8].
For example, for (m, n) = (3, 2), the bijection with size 3 subsets of [5] is

So here we have a bijection between lattice paths of (m,n) with-
0.2] In a n x n grid it is very easy to notice that,
The lattice paths which cross the (main diagonal) y = x line have atleast one point in its sequence of E's and N's, where #N's becomes more than #E's (or #N - #E > 0).
And vertices where a lattice path intersects with the diagonal are the points in the sequence where #N's and #E's becomes equal.
e.g. ENNEENEN in 4X4 grid, at 3rd move #N's = 2 is more than #E's = 1, also at 2nd, 4th, 6th, 8th moves #N = #E.
A Dyck path is a lattice path that does not go above the line y = x or #E's >= #N's in every prefix of the sequence.
And, lattice paths that cross y = x line are non-Dyck paths.

1] Dyck Paths:
Proposition: Lattice paths in n x n grid that cross the diagonal (non-Dyck paths) are in bijection with lattice paths in the (n − 1) × (n + 1) grid.
Proof. Given a lattice path P in n x n grid crossing the line y = x. From the first vertex in the path that lies above y = x line, take reflection of steps. For example;

In P, blue portion ends at vertex (with last step p) which is the first vertex above y = x line. Keeping all steps same till p (blue part) and taking the reflection of all steps after this vertex (red part), we construct a lattice path $Q_{p}$.
In the blue portion, there will always be exactly one more north(N) step than east step(E) by the definition of p. Since there are exactly n north steps and n east steps in P, there must be exactly one more east steps than north steps in the red portion of P.
Thus, both the blue and red portions of $Q_{p}$ will have one more north steps than east steps. Thus, $Q_{p}$ will have n − 1 total east steps and n + 1 total north steps. In other words, $Q_{p}$ will be a lattice path in the (n − 1) × (n + 1) grid. For the inverse bijection, just draw in the n × n diagonal in the (n − 1) × (n + 1) grid and do the same reflection again!
Hence, we have proven that Dyck paths of n x n grid are in bijection with lattice paths of the (n − 1) × (n + 1) grid. Now, it's time to introduce the Hero of the Town, Catalan Numbers,
$$\#\;of Dyck\; paths = Total\; lattice\; paths - \#\; of\; nonDyck\; paths$$
$$=\binom{2n}{n} - \binom{2n}{n-1}$$
After some complicated simplifications, it becomes, $$\frac{1}{n+1} \binom{2n}{n} = C_{n}(n^{th} catalan\:number)$$
Proposition: $C_{n}$ counts the number of lattice paths in the n × n grid that do not cross the line y = x (Dyck paths).
For some more examples:-
For n = 2, there are four bad paths, and they biject to all lattice paths in the 1 × 3 grid (shown in figure below): And there are $C_{2}$ = 2 good paths (left for readers).

And, there are $C_{4}$ = 14 good paths in a 4 × 4 grid:

2] Balanced Parentheses:
A sequence is said to have balanced parentheses, if there are exactly n opening brackets and n closing brackets, and every opening bracket has a corresponding closing bracket of exact same type, properly nested in correct sequence and no bracket closes before its matching opener.
Proposition: Number of balanced parenthesis sequences with exactly n opening brackets and n closing brackets = $C_{n}$
Proof. Simply by replacing every opening bracket with E and every closing bracket with N, balanced parenthesis problem can be transformed into Dyck path problem we saw earlier. One can also show reverse bijection, hence proving that balanced parenthesis sequences are in bijection with Dyck paths.
3] Ballot Sequences:
A ballot sequence of length 2n is a sequence with n −1’s and n 1’s such that sum of every prefix of the sequence is nonnegative. Equivalently, as you read the sequence left-to-right, you always encounter at least as many 1's as −1’s.
For example, (1, −1, 1, 1, −1, −1, −1, 1) has partial sums 1, 0, 1, 2, 1, 0, −1, and 0, so it is not a ballot sequence.
For n = 3, there are five ballot sequences: (1, 1, 1, −1, −1, −1) (1, 1, −1, 1, −1, −1) (1, 1, −1, −1, 1, −1) (1, −1, 1, 1, −1, −1) (1, −1, 1, −1, 1, −1)
We show that ballot sequences are counted by Catalan numbers through a bijection to Dyck paths!
Proposition: There are $C_{n}$ ballot sequences of length 2n.
Proof. Given a ballot sequence, replace each 1 by E and each −1 by N and then it can be shown that Ballot Sequence problem are in bijection with Dyck paths.
When n = 3, we get the bijection:

4] Stack-sortable Permutation
A one stack-sortable permutation (also called a tree permutation) is a permutation whose elements may be sorted by an algorithm whose internal storage is limited to a single stack data structure.
Proposition: The number of one stack-sortable permutations of length n is the $n^{th}$-Catalan number $C_{n}$.
Algorithm to check whether a given permutation π is sorted:
- Initialize an empty stack
- For each input value x:
- While the stack is nonempty and x is larger than the top item on the stack, pop the stack to the output
- Push x onto the stack
- While the stack is nonempty, pop it to the output
This algorithm correctly sorts some input permutations, and fails to sort others. If it is successfull, i.e. output sequence is in sorted order, then we say that the input permutation π is one stack-sortable. If this algorithm fails to sort π, then π cannot be sorted with a single stack.
For example, consider the permutation π = 2413

OBSERVATIONS-
a] If the elements a, b and c occur in the permutation π where a < b < c and b precedes c precedes a, then we say that π contains a 231-pattern.
Theorem: A permutation π is one stack sortable if and only if it does not contain a 231-pattern.
For instance, the sequence 3,2,1 is correctly sorted: the three elements are all pushed onto the stack, and then popped in the order 1,2,3. However, the sequence 2,3,1 is not correctly sorted: the algorithm first pushes 2, and pops it when it sees the larger input value 3, causing 2 to be output before 1 rather than after it.
b] Because of the 231-pattern limitation, many permutations are not one stack sortable. To increase the number of sortable permutations, we can use two stacks. Take the output sequence of first stack and give it as a input to second stack. If finally obtained output sequence is sorted, then we say that the permutation π is two stack sortable.
Theorem: The number of 2 stack sortable n-permutations is $$\frac{2(3n!)}{(n+1)! (2n+1)!}$$
(proof conjectured by Julian West. For this blog a proof will not be shown)
5] Non-crossing Matchings and Non-nesting Matchings
A matching on 2n vertices can be drawn as a way to connect 2n nodes on the x-axis by arcs, with every node connected to precisely one other node by an arc drawn in the upper halfplane.
Non-crossing matchings- A matching is non-crossing if all arcs can be drawn in a way such that no pair of arcs intersects.
Proposition: The number of non-crossing matchings on 2n vertices is the $n^{th}$-Catalan number $C_{n}$.
For example, All non-crossing matchings on 6 vertices are shown in figure below,

Non-nesting matchings- A matching is non-nesting if all the arcs can be drawn in a way such that no arc is above the other, or, equivalently, there is no pair of arcs with ends at points (a1, b1) and (a2, b2) such that a1 < a2 < b2 < b1.
Proposition: The number of non-crossing matchings on 2n vertices is the $n^{th}$-Catalan number $C_{n}$.
For example, All non-nesting matchings on 6 vertices are shown in figure below,

6] Binary Trees
Proposition: Number of binary trees on n (unlabelled) vertices is the $n^{th}$-Catalan number $C_{n}$.
7] Binary Search Trees
Proposition: The number of structurally unique Binary Search Trees (BSTs) on n distinct keys corresponds exactly to the $n^{th}$-Catalan number $C_{n}$
Because a valid BST requires that all values in the left subtree be smaller than the root and all values in the right be larger, the trees are purely determined by their structural branching shapes.
8] Full Binary Trees
There is a bijection b/w full binary trees on 2n+1 vertices(or n+1 leaves) and binary trees on n vertices, therefore;
Proposition: The number of Full Binary Trees on n+1 leaves equals to the $(n)^{th}$-Catalan number $C_{n}$.
9] Mountain Ranges
A Mountain range is defined to be a path of n upstokes and n downstrokes that starts from (0,0) and ends at (2n,0) and never goes below horizon (x-axis).
For exmaple, below figure shows all possible mountain ranges of 3-upstrokes & 3-downstrokes (length 6)

Proposition: $C_{n}$ is equal to the number of mountain ranges of length 2n consisting of n upstrokes and n downstrokes.
Below are two nice bijective proofs:
Proof 1. Show the bijection between this problem and Dyck path problem.
Given a sequence of n-upstrokes and n-downstrokes ending at (2n,0), convert horizon to y = x line of n x n grid with region above horizon to the region below y = x line. (doing this transforms our problem statement to finding dyck paths in n x n grid. You can relate to further steps if you understood dyck path proof)
Identify the first vertex below horizon (as first bad vertex) and take reflection of all strokes in the path after that vertex(upstrokes -> downstrokes and vice versa), keeping the part of path upto that vertex same. We will observe that we always end up at (2n, -2) irrespective of any bad path you take.
Lets call the paths that crosses horizon as bad paths and that which don't as good paths. Also, we name lattice path before transformation (blue one) as P and after transformation (blue one upto first bad vertex and red one after that) as Q.

So, we proved that bad paths ending at (2n,0) is in bijection with all paths ending at (2n,-2), i.e. $\#of\;Bad\; paths\; ending\; at\; (2n,0) = Total\; lattice\; paths\;ending\;at\;(2n,-2)$
But, what is total paths ending at (2n,-2)?
Paths in P ends up at (2n,0) because it has exactly n upstrokes and n downstrokes. Upto first bad vertex, # of downstrokes are exactly one more than # of upstrokes. Therefore, in remaining part of the path, # of upstrokes are exactly one more than # of downstrokes in P. Thus in Q, both part (one uptil P and other after P) has # of downstrokes exactly one more than # of upstrokes, i.e. (n-1) upstrokes and (n+1) downstrokes.
$$Total\; lattice\; paths\;ending\;at\;(2n,-2) = \binom{2n}{n-1}=\#of\; Bad\; paths\;ending\;at\;(2n,0)$$
$$\#of Good\; paths\; ending\; at\; (2n,0) = Total\; lattice\; paths\;ending\;at\;(2n,0) - \#of\; Bad\; paths\;ending\;at\;(2n,0)$$
$$=\binom{2n}{n} - \binom{2n}{n-1}$$
$$=\frac{1}{n+1} \binom{2n}{n} = C_{n}(n^{th} catalan\:number)$$
Each good path is termed as a mountain range.