Topics

The Catalan numbers () count various recursive patterns, with balanced parentheses being a classic example. Let’s break this down step by step:

First, what are we counting?

  • represents the number of ways to properly match n pairs of parentheses
  • For example, when n=2, we have valid arrangements: (()) and ()()

Now, let’s understand the recursive formula using n=3 as an example. The key insight is:

  • Every valid sequence must start with an opening parenthesis (
  • This opening parenthesis must have a matching closing parenthesis )
  • These matching parentheses divide our sequence into two parts: what’s inside them and what’s outside them

For n=3, let’s see how this works:

  1. If we have 1 pair inside the first matching parentheses:

    • Inside: We need to arrange 1 pair → ways
    • Outside: We have 1 pair left → ways
    • Example: (())()
  2. If we have 0 pairs inside:

    • Inside: Empty → ways (just 1 way)
    • Outside: 2 pairs → ways
    • Example: ()()() or ()(())
  3. If we have 2 pairs inside:

    • Inside: 2 pairs → ways
    • Outside: 0 pairs → ways
    • Example: ((()))

The total number is the sum of all these possibilities:

This pattern generalizes to the formula (combinatorial proof here):

The formula captures the fact that we’re:

  1. Always using one pair of parentheses as our “outer frame”
  2. Splitting the remaining n-1 pairs between “inside” (i pairs) and “outside” (n-1-i pairs)
  3. Multiplying the possibilities for each part (because we can combine any valid inside arrangement with any valid outside arrangement)
  4. Summing over all possible ways to split the remaining pairs

This way to breaking problems is a common pattern that is seen in many places: