{
  "id": "catalan-number",
  "title": "Catalan Number",
  "lang": "en",
  "source_lang": "en",
  "summary": "Catalan numbers form an integer sequence that counts many recursively structured objects, including balanced parentheses, binary trees, polygon triangulations, and noncrossing partitions.",
  "category": "mathematics",
  "subcategory": "discrete-logic",
  "type": "concept",
  "aliases": [
    "Catalan sequence",
    "Segner numbers"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/catalan-number/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/catalan-number/",
      "json": "https://aiwiki.page/zh/catalan-number.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The Catalan numbers are a sequence of positive integers that occurs throughout combinatorics, especially in problems involving nesting, branching, and noncrossing structures. With indexing beginning at zero, the \\(n\\)th Catalan number is\n\n\\[C_n=\\frac{1}{n+1}\\binom{2n}{n} =\\frac{(2n)!}{n!(n+1)!}, \\qquad n\\geq 0.\\]\n\nThe sequence begins\n\n\\[1,\\ 1,\\ 2,\\ 5,\\ 14,\\ 42,\\ 132,\\ 429,\\ 1430,\\ 4862,\\ 16796,\\ldots.\\]\n\nAlthough many of the objects counted by these numbers look unrelated, their recursive decompositions often have the same form. Correspondences between these objects explain why the same sequence repeatedly appears."
    },
    {
      "heading": "Definition and recurrence relations",
      "text": "In the defining formula, \\(\\binom{2n}{n}\\) is a central binomial coefficient, and the exclamation mark denotes a factorial. The initial value \\(C_0=1\\) represents an empty structure in many counting interpretations.\n\nA fundamental recurrence relation is\n\n\\[C_0=1,\\qquad C_{n+1}=\\sum_{k=0}^{n}C_kC_{n-k} \\quad(n\\geq 0).\\]\n\nFor example,\n\n\\[C_3=C_0C_2+C_1C_1+C_2C_0=2+1+2=5.\\]\n\nThis recurrence describes an object consisting of a distinguished root or outer component together with two ordered substructures. If their sizes are \\(k\\) and \\(n-k\\), they can be chosen in \\(C_kC_{n-k}\\) ways. Summing over all possible splits gives the total.\n\nThe explicit formula also yields a first-order recurrence:\n\n\\[C_0=1,\\qquad C_{n+1}=\\frac{2(2n+1)}{n+2}C_n.\\]\n\nUnlike the convolution recurrence, this formula computes each new term directly from the preceding one.\n\nAnother useful identity is\n\n\\[C_n=\\binom{2n}{n}-\\binom{2n}{n+1}.\\]\n\nBesides establishing that the closed form is an integer, this expression arises naturally from a reflection argument for lattice paths."
    },
    {
      "heading": "Principal counting interpretations",
      "text": "Balanced parentheses\n\nThe number \\(C_n\\) counts correctly balanced strings containing \\(n\\) opening and \\(n\\) closing parentheses. A string is balanced when every initial segment contains at least as many opening as closing parentheses, and the total numbers are equal.\n\nFor \\(n=3\\), the five strings are\n\n((()))\n(()())\n(())()\n()(())\n()()()\n\nEvery nonempty balanced string has a unique decomposition\n\n\\[(P)Q,\\]\n\nwhere \\(P\\) and \\(Q\\) are themselves balanced strings. The closing parenthesis displayed after \\(P\\) is the one matching the first opening parenthesis. If \\(P\\) contains \\(k\\) pairs and the entire string contains \\(n+1\\) pairs, then \\(Q\\) contains \\(n-k\\) pairs. This gives the Catalan recurrence.\n\nDyck paths\n\nA Dyck path of semilength \\(n\\) is a lattice path from \\((0,0)\\) to \\((2n,0)\\), with steps\n\n\\[U=(1,1),\\qquad D=(1,-1),\\]\n\nthat never goes below the horizontal axis. There are \\(C_n\\) such paths.\n\nThe correspondence with balanced parentheses replaces each opening parenthesis by \\(U\\) and each closing parenthesis by \\(D\\). The balance condition becomes the requirement that the path remain at nonnegative height.\n\nEquivalently, \\(C_n\\) counts paths from \\((0,0)\\) to \\((n,n)\\), using north and east steps, that never rise above the diagonal \\(y=x\\).\n\nOrdered full binary trees\n\nThe number \\(C_n\\) counts rooted, ordered, full binary trees with \\(n\\) internal vertices. Here:\n\n- every internal vertex has exactly two children;\n- the two children are distinguished as left and right;\n- a tree with \\(n\\) internal vertices has \\(n+1\\) leaves.\n\nFor a nontrivial tree, removing the root leaves a left subtree and a right subtree. If the tree has \\(n+1\\) internal vertices and the left subtree has \\(k\\), the right subtree has \\(n-k\\), again producing the Catalan recurrence.\n\nThe qualifications “ordered” and “full” matter: changing the class of trees changes the counting sequence. Catalan numbers also count rooted plane trees with \\(n\\) edges, where the children of each vertex are linearly ordered.\n\nParenthesizations of a product\n\nThere are \\(C_n\\) ways to fully parenthesize a product of \\(n+1\\) factors while preserving their order and using only binary operations.\n\nFor four factors, the five possibilities are\n\n\\[((ab)c)d,\\quad (a(bc))d,\\quad (ab)(cd),\\quad a((bc)d),\\quad a(b(cd)).\\]\n\nThese are syntactic arrangements. If the operation is associative, all arrangements have the same value, but they remain distinct parenthesizations. For matrix multiplication, different parenthesizations may require different numbers of arithmetic operations even though the resulting matrix is unchanged.\n\nPolygon triangulations\n\nFor \\(n\\geq 1\\), the number of triangulations of a convex polygon with \\(n+2\\) vertices is \\(C_n\\). A triangulation uses nonintersecting interior diagonals to divide the polygon into triangles.\n\nA pentagon therefore has \\(C_3=5\\) triangulations. The polygon’s vertices are regarded as fixed and distinguishable; triangulations related by rotation or reflection are not identified.\n\nFixing one boundary edge and considering the triangle incident to it decomposes the remaining region into two smaller polygonal regions. This yields another version of the Catalan recurrence, with empty regions handled by the convention \\(C_0=1\\).\n\nNoncrossing partitions and pattern-avoiding permutations\n\nA noncrossing partition of \\(n\\) points placed in order around a circle is a partition whose blocks do not cross. More precisely, there must not be four points in cyclic order \\(a,b,c,d\\) such that \\(a,c\\) lie in one block and \\(b,d\\) in another. The number of such partitions is \\(C_n\\).\n\nCatalan numbers also count several classes of restricted permutations. For example, \\(C_n\\) is the number of permutations of \\(1,\\ldots,n\\) avoiding the pattern \\(231\\): there are no indices \\(i<j<k\\) for which\n\n\\[\\pi_j>\\pi_i>\\pi_k.\\]"
    },
    {
      "heading": "A reflection proof of the formula",
      "text": "There are\n\n\\[\\binom{2n}{n}\\]\n\nunrestricted paths containing \\(n\\) up-steps and \\(n\\) down-steps. To count Dyck paths, subtract the paths that reach height \\(-1\\).\n\nFor each such bad path, reflect the initial segment ending at its first visit to height \\(-1\\), interchanging up-steps and down-steps. The transformed path has \\(n+1\\) up-steps and \\(n-1\\) down-steps, ending at height \\(2\\).\n\nThis transformation is reversible: every path of length \\(2n\\) ending at height \\(2\\) first reaches height \\(1\\), and reflecting its initial segment through that point recovers a bad path. Thus it is a bijection, and the number of bad paths is\n\n\\[\\binom{2n}{n+1}.\\]\n\nConsequently,\n\n\\[C_n =\\binom{2n}{n}-\\binom{2n}{n+1} =\\frac{1}{n+1}\\binom{2n}{n}.\\]\n\nThis is an instance of the reflection principle in path enumeration."
    },
    {
      "heading": "Generating function",
      "text": "Define the ordinary generating function\n\n\\[C(x)=\\sum_{n=0}^{\\infty}C_nx^n.\\]\n\nThe convolution recurrence translates into\n\n\\[C(x)=1+xC(x)^2.\\]\n\nSolving this quadratic equation gives\n\n\\[C(x)=\\frac{1-\\sqrt{1-4x}}{2x}.\\]\n\nThe minus sign is selected because this branch has a power-series expansion with constant term \\(1\\); the other branch does not. At \\(x=0\\), the expression is interpreted by its removable limit.\n\nAs a formal power series, the identity encodes the recurrence without requiring analytic convergence. As a complex power series, it has radius of convergence \\(1/4\\).\n\nThe square-root form is characteristic of many recursively defined tree-like classes. It also provides a route from the recurrence to the explicit coefficient formula."
    },
    {
      "heading": "Growth and probability",
      "text": "Using Stirling’s approximation in the factorial formula gives\n\n\\[C_n\\sim\\frac{4^n}{\\sqrt{\\pi}\\,n^{3/2}} \\qquad(n\\to\\infty).\\]\n\nMore precisely,\n\n\\[C_n= \\frac{4^n}{\\sqrt{\\pi}\\,n^{3/2}} \\left(1-\\frac{9}{8n}+O(n^{-2})\\right),\\]\n\nwhere \\(O(\\cdot)\\) is big-O notation. The successive-term ratio satisfies\n\n\\[\\frac{C_{n+1}}{C_n} =4-\\frac{6}{n+2},\\]\n\nand therefore tends to \\(4\\).\n\nThe path interpretation gives a simple probability identity. If a path is selected uniformly from all paths with \\(n\\) up-steps and \\(n\\) down-steps, then\n\n\\[\\Pr(\\text{the path never goes below }0) =\\frac{C_n}{\\binom{2n}{n}} =\\frac{1}{n+1}.\\]\n\nEquivalently, for a symmetric random walk conditioned to return to zero after \\(2n\\) steps, the probability of remaining nonnegative throughout is \\(1/(n+1)\\)."
    },
    {
      "heading": "Computation and applications",
      "text": "The first-order recurrence computes the sequence using exact integer arithmetic. For each step, the numerator\n\n\\[2(2n+1)C_n\\]\n\nis divisible by \\(n+2\\). Multiplication before division avoids truncation in integer arithmetic. Direct floating-point evaluation of factorials can overflow even when the final result remains representable.\n\nThe convolution recurrence takes \\(O(N^2)\\) arithmetic operations to calculate all terms through \\(C_N\\), while the first-order recurrence takes \\(O(N)\\). These are arithmetic-operation counts rather than bit-complexity bounds: the number of bits needed to store the terms increases with \\(n\\).\n\nIn computer science, Catalan numbers describe the sizes of search spaces involving expression trees, nested syntax, and parenthesizations. They explain why exhaustive enumeration quickly becomes impractical.\n\nCounting and optimization are distinct tasks. A matrix-chain multiplication problem has \\(C_n\\) possible parenthesizations for \\(n+1\\) matrices, yet dynamic programming can find an optimal parenthesization without listing them all.\n\nCatalan decompositions also support uniform random generation. To generate a uniformly chosen ordered full binary tree with \\(n+1\\) internal vertices, select the left-subtree size \\(k\\) with probability\n\n\\[\\frac{C_kC_{n-k}}{C_{n+1}},\\]\n\nthen independently generate uniform left and right subtrees of the selected sizes. Choosing the split uniformly would generally not produce a uniform distribution on trees."
    },
    {
      "heading": "History and generalizations",
      "text": "The sequence is named after the Belgian mathematician Eugène Charles Catalan, who studied parenthesization problems in the nineteenth century. Its history predates that work: Leonhard Euler investigated polygon triangulations in the eighteenth century, and Johann Andreas von Segner obtained the associated recurrence. The same numbers also appeared independently in work by the Mongolian mathematician Minggatu.\n\nA standard generalization is given by the Fuss–Catalan numbers:\n\n\\[F_n^{(p)} =\\frac{1}{(p-1)n+1}\\binom{pn}{n}, \\qquad p\\geq 2.\\]\n\nThey count rooted ordered full \\(p\\)-ary trees with \\(n\\) internal vertices, meaning that each internal vertex has exactly \\(p\\) ordered children. For \\(p=2\\), they reduce to the ordinary Catalan numbers. Their generating function satisfies\n\n\\[F(x)=1+xF(x)^p.\\]\n\nThe Narayana numbers refine Catalan counting:\n\n\\[N(n,k)=\\frac{1}{n}\\binom{n}{k}\\binom{n}{k-1}, \\qquad 1\\leq k\\leq n.\\]\n\nThey count Dyck paths of semilength \\(n\\) with exactly \\(k\\) peaks, where a peak is an up-step immediately followed by a down-step. Consequently,\n\n\\[\\sum_{k=1}^{n}N(n,k)=C_n.\\]"
    }
  ],
  "links": [
    "integer",
    "combinatorics",
    "binomial-coefficient",
    "factorial",
    "recurrence-relation",
    "binary-tree",
    "matrix-multiplication",
    "polygon",
    "set-partition",
    "permutation",
    "bijective-function",
    "generating-function",
    "power-series",
    "stirlings-approximation",
    "big-o-notation",
    "probability",
    "random-walk",
    "computer-science",
    "dynamic-programming",
    "leonhard-euler"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}