Popular Posts

Wednesday, July 20, 2011

combinations of n-pairs of parentheses.

Problem:

Implement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses.
EXAMPLE:
input: 3 (e.g., 3 pairs of parentheses)
output: ()()(), ()(()), (())(), ((()))

Solution:
Solve recursively.

Complexity:
Code:

No comments:

Post a Comment