The Catalan Numbers
Explore the calculation of Catalan numbers by implementing both naive and dynamic programming solutions. Understand the recursive definition and learn to optimize it using memoization and tabulation, reducing time complexity from exponential to polynomial. This lesson guides you through computing Catalan numbers efficiently for use in combinatorial problems.
Statement
Given a number n, find the Catalan number.
Catalan numbers are a special sequence of numbers given by the following set of formulas:
The first expression gives the base case of the formula. The second expression says that the Catalan number is simply the sum of products of specific Catalan number pairs. These specific pairs are just Catalan numbers with the same distance from either end of the series.
for example would be equal to:
...