how to sort the output
https://ide.codingblocks.com/s/60273
please help
Regarding generate parenthesis
Hi Kushagra, to sort the output, comment lines 30-39 of your code and shift
if(cc < oc){
in[i] = ‘)’;
generateparenthesis(in,i+1,oc,cc+1,n);}
above this
if(oc < n){
in[i] = ‘(’;
generateparenthesis(in,i+1,oc+1,cc,n);
}
I’ve made these changes in https://ide.codingblocks.com/s/60278.
But this code still runs fine only till n=4. It gives error for greater values of n because of the increased complexity because of strcpy being used many times. Try to optimise your code.