1

If we want to count how many possible pairs $n$ of parenthesis we have when $n = 1$ then I think the way to count is $2 \choose 1$ since if we have $2$ symbols and we pick $one$ position to place $1$ the other will be at the other position hence total of ${2 \choose 1} = 2$.
But we have:
$()$ and $)($ and $(($ and $))$ total of $4$

For the case of $n = 2$, following the same reasoning i.e. I have $4$ positions for the symbols, I pick any $2$ and use that as the count I get ${4 \choose 2} = 6$ but when I actually enumerate all the cases I count $9$
I.e.

  1. $()()$
  2. $(())$
  3. $))()$
  4. $((()$
  5. $()))$
  6. $())($
  7. $)()($
  8. $(((($
  9. $))))$

I thought the idea is that we have $n + n$ positions and we care about choosing $n$ and get the total count.
E.g. I have seen the same logic when counting lattice paths

What am I messing up here?

RobPratt
  • 50,938
Jim
  • 1,729
  • Why is )))) allowed for $n=2$ but $))$ not allowed for $n=1$? – Phicar Apr 26 '22 at 11:14
  • @Phicar: You are right. I think I have messed this up completely – Jim Apr 26 '22 at 11:16
  • @Phicar: Updated the post. – Jim Apr 26 '22 at 11:17
  • 1
    Now why is that )))( is not there? My point is that if you want all of them then you have two options per character..so $2^n$. Now, in the context of parenthesis, one usually wants the parenthesis to be balances..Is that what you want? – Phicar Apr 26 '22 at 11:20
  • @Phicar: I am looking into this in the context of catalan numbers. Apparently the number of valid parenthesis is $\frac{1}{n + 1}{2n \choose n}$ so I tried to follow the logic I have seen for other places i.e. how to find all the cases including bad ones which I thought is $2n \choose n$ – Jim Apr 26 '22 at 11:32
  • 2
    then you are looking for sequences having the same number of open and closed parenthesis. In that context, (((( is not a valid sequence but )()( or ()() are. So, you choose the indices in which you place open parenthesis and the $2n-n$ rest of them are closed ones. – Phicar Apr 26 '22 at 11:35
  • 1
    Now... yet another common problem asked in exercises is to count the number of parentheses where they can be considered syntactically correct. That is, at any point in the sequence you always have had at least as many open parentheses as you have had close parentheses. (()) is valid, ()() is valid, but ())( is not and )()( is not. For that see Dyck words and Catalan numbers. – JMoravitz Apr 26 '22 at 12:10
  • Yes, $\ \frac{1}{n+1}{2n\choose n}={2n\choose n}- {2n\choose n+1}\ $ is the number of sequences of $\ n\ $ pairs of balanced parentheses. The answer to this post gives a derivation of the formula. – lonza leggiera Apr 26 '22 at 12:16

0 Answers0