Writing a code in C++
Implement an algorithm to print all valid, that is, properlyopened and closed, combinations of n−pairs of parenthesis. Further,fill in the parenthesis with the number indicating the number ofpairs it is enclosed in. For example, if n = 2, the output wouldbe:
(1)(1) ((2))
and if n = 3, the output would be: (1)(1)(1) ((2)(2)) (1)((2))((2))(1) (((3)))
Note that the number of such pairs is a Catalan number, givenby:
1. Implement an algorithm to print all valid, that
OR
OR