Algorithm

The nth Catalan Number (Cn) can be calculated by essentially one formula (as mentioned above) but the approaches can be different. I will be discussing three methods to find nth Catalan Number. All of them would rely mostly on combinatorial mathematics along with array and recurrence utilisation.

Calculating Catalan Numbers using Recursive Solution

This method utilizes the power of recursive computation and is a lot easier to manipulate. The basic Mathematical concept behind this algorithm is :

Using this methid, to calculate the n th catalan number, one needs to calculate all previous catalan numbers.

Calculating Catalan Numbers using Simple Definition Approach

We can use the intial definition to get the solution for this problem. One can simply find the combination of 2n objects among which n are to be selected and use that. It gives you the best performance for large test cases.

Applications

The applications of Catalan Numbers are quite evident in various fields of studies. I will be dicussing a few of them in the field of Combinatorics.

Cn is the number of Dyck words of length 2n. A Dyck word is a string consisting of n X's and n Y's such that no initial segment of the string has more Y's than X's. For example, the following are the Dyck words of length 6:

XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY.

A modified version of this issue is also known as the bracket problem - in which we have to match opened and closed parenthesis- which many might've come across in problem solving using stacks

Successive applications of a binary operator can be represented in terms of a full binary tree. (A rooted binary tree is full if every vertex has either two children or no children.) It follows that Cn is the number of full binary trees with n + 1 leaves:

A convex polygon with n + 2 sides can be cut into triangles by connecting vertices with non-crossing line segments (a form of polygon triangulation). The number of triangles formed is n and the number of different ways that this can be achieved is Cn. The following hexagons illustrate the case n = 4:

In chemical engineering Cn-1 is the number of possible separation sequences which can separate a mixture of n components.

Dyck Paths are also field of application for the Catalan Numbers. A Dyck path is a series of equal length steps that form a stariway walk from (0,0) to (n,n) that will lie strictly below, or touching the diagonal x=y.

Clearly, each acceptable route is either above the diagonal or below the diagonal and both of these paths are symmetric. So we calculate the number of paths below the diagonal and multiply it by 2. Each route is a sequence of n northernly blocks n westernly blocks. We can gather the conclusion that number of acceptable routes above the diagonal equals the nth Catalan Number

Binary trees: A rooted binary tree is a tree with one root node, where each node has either zero or two branches descending from it. A node is internal if it has two nodes coming from it. How many rooted binary trees are there with n internal nodes? Yes, they are nth Catalan Numbers

Determining Monotonic Lattice Paths. They can be straight away calculated by the usage of Catalan Numbers! The number of paths from (0,0) to (n,n) which crosses XY line are also equal to Cn!