Exercise · Volume 1 · 2.2.1-4
Exercise 2.2.1-4
not stated yet in Lean solution written
| Rating | M34 |
|---|---|
| Markers | M (mathematical) |
| Kind | K3, find a value: compute a number, a set or a closed form from the written solution |
| Section | Section 2.2.1 of Volume 1 |
The task
Find a simple formula for , the number of permutations of elements that a stack can give.
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
Use Exercise 2.2.1-3. The number is the number of admissible sequences of letters S and letters X.
Hint 2
Split an admissible sequence at the first time when the stack becomes empty.
Solution
Show the solution
Plan. Count admissible sequences by their first return to the empty stack. This gives a recurrence and a generating function. Then read off the coefficients.
By Exercise 2.2.1-3, is the number of admissible sequences with letters of each kind. Put for the empty sequence.
A non-empty admissible sequence starts with S. Let the stack become empty for the first time after the matching X. Then the sequence has the form S X , where and are admissible. If has letters of each kind, then has . This split is unique, so
Let . The recurrence says . The root with is
By the binomial series, The reason is that for . Hence and the coefficient of is
Check
A search over all stack runs gave for . The formula gives the same values. The two forms of the formula agree for these .
Remarks
The numbers are the Catalan numbers. The book's answer takes another route, through a reflection of the bad sequences.
This solution is drafted, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.