Question

Say we'd like to count the number of different parenthesizations of n pairs of brackets but having a fixed number of "()" pairs. How do we count these.

ex: for n = 3. i.e 3 pairs of parenthesizations, if we want number of parenthizations with k = 2 pairs of "()" the number of ways is 3.

()(())

(())()

(()())

for n = 4,k = 2, it will be 6

((()()))

()((()))

(())(())

(()(()))

((()))()

((())())

Was it helpful?

Solution

I'm pretty sure this is A001263, a.k.a. the Narayana numbers, and that the formula is

T(n,k) = C(n-1,k-1) C(n,k-1)/k with 1<=k<=n

One interpretation of A001263 is that T(n,k) is the number of Dyck n-paths with exactly k peaks, and you can interpret each Dyck step as either ( or ) and each peak as ().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top