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 . <[email protected]> wrote:

> thanks a lot gene. :)
>
>
> On Fri, Sep 16, 2011 at 7:00 PM, Gene <[email protected]> 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
>>
>> [][][][] *
>> [][][[]]
>> [][[]][]
>> [][[][]]
>> [][[[]]]
>> [[]][][] *
>> [[]][[]]
>> [[][]][]
>> [[][][]]
>> [[][[]]]
>> [[[]]][]
>> [[[]][]]
>> [[[][]]]
>> [[[[]]]]
>>
>> I have put *'s after the two cases that have [ at positions 5 and 7
>> (with 1-based indexes).
>>
>> So the answer is 2.
>>
>> On Sep 16, 8:46 am, "mc2 ." <[email protected]> wrote:
>> > Hey guys,
>> >
>> > i am trying to solve this problem :http://www.spoj.pl/problems/SQRBR/
>> >
>> > But i can't decipher the problem what it is asking for . Could someone
>> >  please give test cases for input set 4 and 5?
>> > What does proper proper bracket expressions mean in these cases?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to