we can use recursion to do that. recursively call parent(left, right),
just make sure that left is always less or equal to right

On Sep 30, 2:56 pm, Nikhil Jindal <fundoon...@yahoo.co.in> wrote:
> Try this:
>
> Find the number of ways for generating n pairs of valid parenthesis.
> A set of parenthesis is said to be valid if at any instant while scanning
> from left to right, the number of opening parenthesis are never less than
> the number of closing parenthesis.
>
> For ex: for n=3, f(n) = 5
>
> ()()(), ((())), (()()), ()(()), (())()
>
> Cheers
> Nikhil Jindal
>
> Please access the attached hyperlink for an important electronic 
> communications 
> disclaimer:http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php

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

Reply via email to