Catalan objects and lattice paths
Derive Catalan counts by a first-return decomposition, a reflection bijection, and reversible path encodings.
On this page
The question for today
What you’ll understand
- Decompose a nonnegative balanced path at its first return.
- Use reflection to count paths violating a prefix restriction.
- Explain which tree and parenthesis conventions produce Catalan numbers.
Balanced counts do not guarantee a valid sequence of nested actions. A closing bracket cannot appear before the opening bracket it closes, even when the final totals agree. Recording openings as up-steps and closings as down-steps converts this prefix condition into a path that never falls below its starting height. Catalan numbers count these paths, along with several other classes connected by explicit encodings. The common number is useful, but the reversible structural connection is what explains it.
The first return determines two smaller paths
A Dyck path of semilength n contains n up-steps and n down-steps, starts and ends at height zero, and has no negative partial height. The empty path is allowed. Every nonempty Dyck path starts upward; pair that first step with the down-step making its first return to zero. Between them lies a smaller Dyck path shifted upward by one unit, and after them lies another Dyck path. The first-return position is unique, so this is a reversible decomposition.
If the inner path has semilength i, the remaining path has semilength n minus one minus i. Summing over i gives the Catalan convolution. Its generating function satisfies : one empty path, or one outer matched pair with two ordered smaller paths. The order of those two roles matters. A formal series with constant term one is determined recursively by this equation, without evaluating it at any real x or appealing to an analytic square-root branch.
Reflect the first violation
There are binomially many unrestricted words with n up-steps and n down-steps. A bad word first reaches height minus one at a unique step. Swap up and down throughout the prefix ending at that first violation, leaving the suffix unchanged. The transformed word has n plus one up-steps and n minus one down-steps, so its endpoint is height two. The inverse reflects the prefix through the first arrival at height one in that transformed word.
The inverse works because every path ending at height two must pass through height one. Before its first such arrival it never exceeds zero, so reflecting that prefix produces a path whose first negative height is precisely minus one at the end of the reflected prefix. Thus reflection is a bijection, not just a heuristic subtraction. Subtracting the transformed-word count from all balanced words produces the Catalan formula. The derivation depends on unit steps and the stated starting boundary; modified steps or barriers require a new argument.
Transporting the count through precise encodings
A balanced-parenthesis word corresponds to a Dyck path by replacing each opening parenthesis with an up-step. Nonnegative prefixes express that no closing parenthesis lacks a preceding match. Full ordered binary trees provide another Catalan class when size means number of internal vertices and every internal vertex has exactly two ordered child positions. The empty internal-vertex structure is represented by a leaf, and removing the root leaves an ordered pair of smaller full binary trees, giving the same recurrence with the same initial value.
A general rooted plane tree has an ordered list of children rather than exactly two child positions. It is counted by a shifted Catalan sequence when size counts all vertices; those size conventions cannot be silently interchanged. Likewise an unordered binary tree identifies child swaps and has a different count. Matching a Catalan number in small cases is therefore only a clue. Specify the structural class, its size statistic, and either its inverse encoding or its recurrence with initial conditions before claiming a Catalan enumeration.
Work it through
Three opening and three closing actions
Count valid balanced-parenthesis words with three pairs, and compare valid paths with all balanced paths.
All balanced six-step paths are obtained by choosing the three up-step positions, giving twenty paths.
Reflection maps bad paths to six-step paths with four up-steps and two down-steps. There are fifteen of these, so five balanced paths never go below zero.
The five parenthesis words are ((())), (()()), (())(), ()(()), and ()()(). Checking each prefix verifies nonnegativity, while their distinct step words verify that no two entries coincide.
Five of the twenty balanced paths are valid. Conditional on having exactly three up-steps in six fair independent steps, the probability of nonnegative prefixes is one quarter.
The living notebook
Explore the model
Interactive lab · probability
Endpoint counts before the prefix filter
Pause and Reset, then set p=0.5 and n=6. Predict the probability of exactly three upward choices, then multiply the middle bar by 64 to recover the twenty balanced paths. Separately apply reflection to determine how many satisfy the prefix constraint.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forThe middle mass is 20/64, but only five of those twenty paths are Dyck paths. This endpoint histogram cannot inspect the order of steps and does not itself enforce the nonnegative-prefix condition.
Pause & reason
Check your understanding
Your turn
Try it yourself
Find the number of Dyck paths of semilength four using the first-return recurrence and verify it with the binomial formula.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The inner semilength can be zero, one, two, or three. Use C₀ through C₃ from the lesson.
Compare with the solution
The recurrence gives C₄=C₀C₃+C₁C₂+C₂C₁+C₃C₀=5+2+2+5=14. Independently the binomial formula gives (1/5)·binom(8,4)=70/5=14. Each summand of the recurrence describes a distinct first-return position, so this calculation also explains the decomposition of the fourteen paths.
Keep the idea
Take it with you
- A prefix restriction contains information that endpoint totals lose.
- First-return decomposition yields the Catalan convolution with an empty base case.
- Tree size and child-order conventions determine which Catalan interpretation applies.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.