This is mainly an application of Catalan Numbers. Total possible valid expressions for input n is n/2’th Catalan Number if n is even and 0 if n is odd.
program in c
2 Articles
2
C++ Programming – Print all possible combinations of r elements in a given array of size n – Mathematical Algorithms – Given an array of size n, and r is 2.