[algogeeks] Re: Easy Dp problem

2011-09-16 Thread Gene
I'll do the 5th example. A proper bracket expression of size n has n ['s and n ]'s and every prefix has no more ]'s than ['s. Test case 5 is n = 4 k = 2, so the possible bracket expressions are [][][][] * [][][[]] [][[]][] [][[][]] [][[[]]] [[]][][] * [[]][[]] [[][]][] [[][][]] [[][[]]]

Re: [algogeeks] Re: Easy Dp problem

2011-09-16 Thread mc2 .
thanks a lot gene. :) On Fri, Sep 16, 2011 at 7:00 PM, Gene gene.ress...@gmail.com wrote: I'll do the 5th example. A proper bracket expression of size n has n ['s and n ]'s and every prefix has no more ]'s than ['s. Test case 5 is n = 4 k = 2, so the possible bracket expressions are

Re: [algogeeks] Re: Easy Dp problem

2011-09-16 Thread mc2 .
Hey guys, I have the following grammar : S - S{S}S or null i want to generate 2n number of brackets using this grammar. I gave it a try but my program is going out of stack.Could someone please help me code this grammar? On Fri, Sep 16, 2011 at 7:11 PM, mc2 . qlearn...@gmail.com wrote:

[algogeeks] Re: Easy Dp problem

2011-09-16 Thread Gene
Generating all strings is probably a dead end as the number of strings is exponential in n and n can be up to 19. This can be solved as a DP with no counting. Your grammar is not useful because it's ambiguous. An LL grammar is S = empty | [ S ] S . However to enumerate, even the LL grammar is