CITE THIS NOTEBOOK: Exploring Catalan numbers by Peter Cullen Burbery. Wolfram Community OCT 14 2022.
I analyze several applications of Catalan numbers.Computations here are based on my recreational mathematics paclet: https://resources.wolframcloud.com/PacletRepository/resources/PeterBurbery/RecreationalMathematics/
Catalan Sequences
Catalan Sequences
Find the 20th totally balanced binary sequence with five 1’s:
In[]:=
CatalanUnrank[5,20]
Out[]=
{0,0,1,0,1,0,1,1,0,1}
Find the number of totally balanced binary sequences with five 1's:
In[]:=
CatalanNumber[5]
Out[]=
42
Show the totally balanced binary sequences with five 1’s:
In[]:=
CatalanUnrank[5,#]&/@Range[0,CatalanNumber[5]-1]
Out[]=
{{0,0,0,0,0,1,1,1,1,1},{0,0,0,0,1,0,1,1,1,1},{0,0,0,0,1,1,0,1,1,1},{0,0,0,0,1,1,1,0,1,1},{0,0,0,0,1,1,1,1,0,1},{0,0,0,1,0,0,1,1,1,1},{0,0,0,1,0,1,0,1,1,1},{0,0,0,1,0,1,1,0,1,1},{0,0,0,1,0,1,1,1,0,1},{0,0,0,1,1,0,0,1,1,1},{0,0,0,1,1,0,1,0,1,1},{0,0,0,1,1,0,1,1,0,1},{0,0,0,1,1,1,0,0,1,1},{0,0,0,1,1,1,0,1,0,1},{0,0,1,0,0,0,1,1,1,1},{0,0,1,0,0,1,0,1,1,1},{0,0,1,0,0,1,1,0,1,1},{0,0,1,0,0,1,1,1,0,1},{0,0,1,0,1,0,0,1,1,1},{0,0,1,0,1,0,1,0,1,1},{0,0,1,0,1,0,1,1,0,1},{0,0,1,0,1,1,0,0,1,1},{0,0,1,0,1,1,0,1,0,1},{0,0,1,1,0,0,0,1,1,1},{0,0,1,1,0,0,1,0,1,1},{0,0,1,1,0,0,1,1,0,1},{0,0,1,1,0,1,0,0,1,1},{0,0,1,1,0,1,0,1,0,1},{0,1,0,0,0,0,1,1,1,1},{0,1,0,0,0,1,0,1,1,1},{0,1,0,0,0,1,1,0,1,1},{0,1,0,0,0,1,1,1,0,1},{0,1,0,0,1,0,0,1,1,1},{0,1,0,0,1,0,1,0,1,1},{0,1,0,0,1,0,1,1,0,1},{0,1,0,0,1,1,0,0,1,1},{0,1,0,0,1,1,0,1,0,1},{0,1,0,1,0,0,0,1,1,1},{0,1,0,1,0,0,1,0,1,1},{0,1,0,1,0,0,1,1,0,1},{0,1,0,1,0,1,0,0,1,1},{0,1,0,1,0,1,0,1,0,1}}
Grouping Symbols
Grouping Symbols
Find all sets of 3 parentheses that are balanced:
In[]:=
AllBalancedGroupingSymbols[{"(",")"},3]
Out[]=
{((())),(()()),(())(),()(()),()()()}
Parentheses ()
Parentheses ()
In[]:=
AllBalancedGroupingSymbols[{"(",")"},4]
Out[]=
{(((()))),((()())),((())()),((()))(),(()(())),(()()()),(()())(),(())(()),(())()(),()((())),()(()()),()(())(),()()(()),()()()()}
Angle Brackets 〈〉
Angle Brackets 〈〉
In[]:=
AllBalancedGroupingSymbols[{"〈","〉"},4]
Out[]=
{〈〈〈〈〉〉〉〉,〈〈〈〉〈〉〉〉,〈〈〈〉〉〈〉〉,〈〈〈〉〉〉〈〉,〈〈〉〈〈〉〉〉,〈〈〉〈〉〈〉〉,〈〈〉〈〉〉〈〉,〈〈〉〉〈〈〉〉,〈〈〉〉〈〉〈〉,〈〉〈〈〈〉〉〉,〈〉〈〈〉〈〉〉,〈〉〈〈〉〉〈〉,〈〉〈〉〈〈〉〉,〈〉〈〉〈〉〈〉}
Square Brackets []
Square Brackets []
In[]:=
AllBalancedGroupingSymbols[{"[","]"},4]
Out[]=
{[[[[]]]],[[[][]]],[[[]][]],[[[]]][],[[][[]]],[[][][]],[[][]][],[[]][[]],[[]][][],[][[[]]],[][[][]],[][[]][],[][][[]],[][][][]}
Curly Brackets {}
Curly Brackets {}
In[]:=
AllBalancedGroupingSymbols[{"{","}"},4]
Out[]=
{{{{{}}}},{{{}{}}},{{{}}{}},{{{}}}{},{{}{{}}},{{}{}{}},{{}{}}{},{{}}{{}},{{}}{}{},{}{{{}}},{}{{}{}},{}{{}}{},{}{}{{}},{}{}{}{}}
Floor Brackets ⌊⌋
Floor Brackets ⌊⌋
In[]:=
AllBalancedGroupingSymbols[{"⌊","⌋"},4]
Out[]=
{⌊⌊⌊⌊⌋⌋⌋⌋,⌊⌊⌊⌋⌊⌋⌋⌋,⌊⌊⌊⌋⌋⌊⌋⌋,⌊⌊⌊⌋⌋⌋⌊⌋,⌊⌊⌋⌊⌊⌋⌋⌋,⌊⌊⌋⌊⌋⌊⌋⌋,⌊⌊⌋⌊⌋⌋⌊⌋,⌊⌊⌋⌋⌊⌊⌋⌋,⌊⌊⌋⌋⌊⌋⌊⌋,⌊⌋⌊⌊⌊⌋⌋⌋,⌊⌋⌊⌊⌋⌊⌋⌋,⌊⌋⌊⌊⌋⌋⌊⌋,⌊⌋⌊⌋⌊⌊⌋⌋,⌊⌋⌊⌋⌊⌋⌊⌋}
Ceiling Brackets ⌈⌉
Ceiling Brackets ⌈⌉
In[]:=
AllBalancedGroupingSymbols[{"⌈","⌉"},4]
Out[]=
{⌈⌈⌈⌈⌉⌉⌉⌉,⌈⌈⌈⌉⌈⌉⌉⌉,⌈⌈⌈⌉⌉⌈⌉⌉,⌈⌈⌈⌉⌉⌉⌈⌉,⌈⌈⌉⌈⌈⌉⌉⌉,⌈⌈⌉⌈⌉⌈⌉⌉,⌈⌈⌉⌈⌉⌉⌈⌉,⌈⌈⌉⌉⌈⌈⌉⌉,⌈⌈⌉⌉⌈⌉⌈⌉,⌈⌉⌈⌈⌈⌉⌉⌉,⌈⌉⌈⌈⌉⌈⌉⌉,⌈⌉⌈⌈⌉⌉⌈⌉,⌈⌉⌈⌉⌈⌈⌉⌉,⌈⌉⌈⌉⌈⌉⌈⌉}
Double Square Brackets 〚〛]
Double Square Brackets 〚〛]
In[]:=
AllBalancedGroupingSymbols[{"〚","〛"},4]
Out[]=
{〚〚〚〚〛〛〛〛,〚〚〚〛〚〛〛〛,〚〚〚〛〛〚〛〛,〚〚〚〛〛〛〚〛,〚〚〛〚〚〛〛〛,〚〚〛〚〛〚〛〛,〚〚〛〚〛〛〚〛,〚〚〛〛〚〚〛〛,〚〚〛〛〚〛〚〛,〚〛〚〚〚〛〛〛,〚〛〚〚〛〚〛〛,〚〛〚〚〛〛〚〛,〚〛〚〛〚〚〛〛,〚〛〚〛〚〛〚〛}
Bracketing Bars
Bracketing Bars
In[]:=
AllBalancedGroupingSymbols[{"",""},4]
Out[]=
{,,,,,,,,,,,,,}
Bracketing Bars
Bracketing Bars
In[]:=
AllBalancedGroupingSymbols[{"",""},4]
Out[]=
{,,,,,,,,,,,,,}
String Template <*…*> symbols
String Template <*…*> symbols
In[]:=
AllBalancedGroupingSymbols[{"<*","*>"},4]
Out[]=
{<*<*<*<**>*>*>*>,<*<*<**><**>*>*>,<*<*<**>*><**>*>,<*<*<**>*>*><**>,<*<**><*<**>*>*>,<*<**><**><**>*>,<*<**><**>*><**>,<*<**>*><*<**>*>,<*<**>*><**><**>,<**><*<*<**>*>*>,<**><*<**><**>*>,<**><*<**>*><**>,<**><**><*<**>*>,<**><**><**><**>}
Association Template <*…*> symbols
Association Template <*…*> symbols
In[]:=
AllBalancedGroupingSymbols[{"<|",">"},4]
Out[]=
{<|<|<|<|>>>>,<|<|<|><|>>>,<|<|<|>><|>>,<|<|<|>>><|>,<|<|><|<|>>>,<|<|><|><|>>,<|<|><|>><|>,<|<|>><|<|>>,<|<|>><|><|>,<|><|<|<|>>>,<|><|<|><|>>,<|><|<|>><|>,<|><|><|<|>>,<|><|><|><|>}
Mountain Range
Mountain Range
I made a function that will make all mountain ranges named DyckPaths:
In[]:=
Multicolumn[DyckPaths[3]]
Out[]=
|
In[]:=
Multicolumn[DyckPaths[4]]
Out[]=
| |||
|
Walks above or below the diagonal
Walks above or below the diagonal
I made a function that plots all walks above or below the diagonal.
Parenthesized Expressions
Parenthesized Expressions
I made another function that calculates the parenthesized expressions with a certain number of variables.
Full Binary Trees
Full Binary Trees
I made a function to list all full binary trees with n leaves.
Regular Polygon Triangulations
Regular Polygon Triangulations
Catalan numbers are also related to triangulations of regular polygons:
Solving Puzzles
Restricted random walks
Restricted random walks
A man walks n blocks north and n blocks west of his residence. Every day he has 2n blocks to walk. How many routes are possible if he never crosses the diagonal line from home to office?
Make a plot:
Count the walks:
Write the answer:
Binary Trees
Binary Trees
A rooted binary tree is a tree with one root node, where each node has either zero or two branches descending from it. A node is internal if it has two nodes coming from it. How many rooted binary trees are there with n internal nodes?
Make a table of the # of full binary trees:
Write the answer:
Applications in Combinatorics
There are many counting problems in combinatorics whose solution is given by the Catalan numbers. The book Enumerative Combinatorics: Volume 2 by combinatorialist Richard P. Stanley contains a set of exercises which describe 66 different interpretations of the Catalan numbers. Following are some examples, with illustrations of the cases C3 = 5 and C4 = 14.