HI Everyone...
I came across this problem on UVa Safe Salutations I know that it can be solved with the Catalan Numbers but I wanna know WHY ???!! In other words I wanna know the proof that Catalan Numbers work on this problem... THANKS !!!
# | User | Rating |
---|---|---|
1 | ecnerwala | 3648 |
2 | Benq | 3580 |
3 | orzdevinwang | 3570 |
4 | cnnfls_csy | 3569 |
5 | Geothermal | 3568 |
6 | tourist | 3565 |
7 | maroonrk | 3530 |
8 | Radewoosh | 3520 |
9 | Um_nik | 3481 |
10 | jiangly | 3467 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | adamant | 164 |
2 | awoo | 164 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 150 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
I came across this problem on UVa Safe Salutations I know that it can be solved with the Catalan Numbers but I wanna know WHY ???!! In other words I wanna know the proof that Catalan Numbers work on this problem... THANKS !!!
Name |
---|
Let all vertices be numbered from 1 to n at clockwise order starting from some vertice. Let's make such sequence b of n elements: if i-th vertice is connected with j and i < j, then b[i] = '(', else b[i] = ')'. Easy to understand, that if graph was correct, than b — is correct bracket sequence, and if graph wasn't correct than b is not correct bracket sequence. So, problem is equivalent to counting number of correct bracket sequences of length 2n and well-known that answer is n-th Catalan number.
Thank You! It seems kind of obvious now... But I still need the "Mathematical" proof !! Like why if I had n pairs of points and I wanna connect them in pairs without making intersection between the lines that connects them I can make this with Cat(n) of ways ??
Because this problem is equivalent to the problem of counting number of correct bracket sequences, so answer is same.