Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of ways of correctly arranging parenthesis

I've been thinking for a while about this problem:

What's the number of ways of correctly* arranging 2*n parenthesis.
*A correctly arranged sequence of parenthesis has an equal number of open and closed parenthesis at its end and a larger or equal amount of open parenthesis than the closed ones throughout the sequence.

For example, for n=3, there are 5 ways: ((())), ()(()), ()()(), (())(), (()()).

I've been thinking of representing nested parenthesis as trees, but didn't get far.

like image 972
Arvid Nyman Avatar asked Dec 21 '15 20:12

Arvid Nyman


1 Answers

Your example equivalent to the number of Dyck words, which can be counted with combinatorics and will be equal to Catalan number:

enter image description here

like image 120
Salvador Dali Avatar answered Oct 03 '22 09:10

Salvador Dali