Book of programming problems

Contains advanced programming problems for schools, colleges and problem-hungry inidividuals

Make all possible combinations of parenthesis placement in a product of n variables
Complexity (1-100): 20
Make all possible combinations of  parenthesis placement in a product of  n letter multipliers: a,b,c,.... All multipliers should be embraced in parenthesis. For example,  '(a*b)*(c*d)*(e*f)' is incorrect placement, because multipliers (a*b) and (c*d) are not embraced in parenthesis. The correct answeer might be the following: '((a*b)*(c*d))*(e*f)'. Double paranthesis and paranthesis around one letter are not permitted, such as in  '((a*b))' and '(a)*b'. Paranthesis around the whole product are not permitted, such as in '((a*b)*c)'.
Example: for n=3, the correct answer is a set of two formulas: a*(b*c) and (a*b)*c.
For n=4, the answer is
a*(b*(c*d))
a*((b*c)*d)
(a*b)*(c*d)
(a*(b*c))*d
((a*b)*c)*d
Solution:Show/hide explanation | Solution.hs
There are no posts in this topic.

Post Reply

Book of programming problems is powered by UseBB 1 Forum Software | Contact Admin