Function Repository Resource:

# DyckWords

Give all possible ways to form proper brackets

Contributed by: Wolfram Staff
 ResourceFunction["DyckWords"][n] gives all possible ways to form proper sets of n pairs of brackets.

## Details and Options

Three conditions define a proper set of brackets: (1) [ ] is a proper set; (2) two proper sets can be concatenated; and (3) a proper set can be placed anywhere inside another proper set.

## Examples

### Basic Examples (3)

Here is the simplest nontrivial example with two pairs of brackets:

 In[1]:=
 Out[1]=

Here are the ways to nest three pairs of brackets:

 In[2]:=
 Out[2]=

There are five ways to do that:

 In[3]:=
 Out[3]=

Dyck words are counted by the Catalan numbers:

 In[4]:=
 Out[4]=
 In[5]:=
 Out[5]=

### Scope (2)

Define the helper function:

 In[6]:=

A Dyck path of length 2n units starts at the origin, goes NE or SE one unit and finishes on the x-axis:

 In[7]:=
 Out[7]=

George Beck

## Version History

• 1.0.0 – 08 July 2019