Given a number 'n' means n*2 opening, closing parentheses can exist , out of which n are opening and n are closing. These parentheses are used for the same purpose of forming an arithmetic expression following the general rule that
1)An opening bracket should have a corresponding closing bracket
2)There must be equal number of opening and closing brackets
3)The expression formed should be valid in terms of nesting of parentheses.
We have to determine the number of possible expressions you can generate using these parenthesis.
Ex: say n = 4 , means there can be 4 opening and 4 closing parentheses.
and the different ways are given below(The variable/numbers inside the parentheses are ignored since they are not important)
( ) ( ) ( ) ( )
( ( ) ) ( ( ) )
( ) ( ( ) ) ( )
( ( ) ) ( ) ( )
( ) ( ) ( ( ) )
( ) ( ( ( ) ) )
( ( ( ) ) ) ( )
Devise a method which would determing the possible ways for any 'N'
Thursday, January 7, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment