Catalan numbers explorer

Catalan number explorer (Dyck paths, parentheses, trees)

Explore Catalan numbers C_n alongside concrete objects: balanced parentheses (Dyck words), Dyck paths, and full binary trees. Switch between exact BigInt and modulo tables, then enumerate or uniformly sample examples with a fixed seed.

All calculations run in your browser. Tree output uses '*' to mark leaves.

How to use (3 steps)

  1. Choose n and a representation tab (parentheses, path, or tree).
  2. Pick enumerate or sample, then set limits and seed as needed.
  3. Review C_n, examples, and the full table, then export CSV or share the URL.

Inputs

Quick n
Representation
Example view
Mode

Result

C_n value

C_n = (1 / (n + 1)) * C(2n, n)
C_0 = 1, C_{n+1} = sum_{i=0..n} C_i * C_{n-i}

How to read the examples

Parentheses use '(' and ')'. Paths use U for up, R for right. Trees use (L,R) with '*' as a leaf.

Enumeration is automatically disabled for large n. Sampling uses a uniform DP method with a fixed seed.

Examples

    Table (C_0 to C_nMax)

    n C_n digits

    Example walkthroughs

    n = 3 (5 strings)

    Balanced parentheses of length 6: ((())), (()()), (())(), ()(()), ()()().

    n = 10 (C_10 = 16796)

    Use sampling to browse examples and export a CSV if you need test data.

    FAQ

    What is a Catalan number?

    Catalan numbers count balanced parentheses, Dyck paths, full binary trees, and many other structures that share the same recurrence.

    Why is enumeration capped?

    The number of examples grows very quickly. Sampling keeps the page responsive while still giving representative outputs.

    Is the sampler uniform?

    Yes. The sampler uses DP counts to choose each step so every Dyck word is equally likely. A fixed seed reproduces the same list.

    How do Dyck paths map to parentheses?

    Map '(' to U and ')' to R. The path stays under the diagonal exactly when the parentheses string is balanced.

    How does polygon triangulation relate?

    The number of triangulations of a convex (n+2)-gon is also C_n, so polygon triangulation is another Catalan structure.

    What tree definition is used?

    This page uses full binary trees with n internal nodes. Leaves are shown as '*', and internal nodes are written as (L,R).

    Related