Generate parenthesis

Why I am not getting any output?

change ur n to 2*n
and limit to n

	generateParenthesis(2*n,"",0,n,0);

hope this will heip u
pls help me by rating my work

There are few mistakes in your code,

  1. since both left and right parenthesis would make up the string so the 2*n should be passed in generateParenthesis()
  2. condition when the no of right parenthesis become more than left ones has to be set
  3. call in addition of β€˜(’ braces first for the recursion to work properly.
  4. limit variable has to be initially n since max left braces can be n
    try to work out on these suggestions.
  1. in the qn, we have to generate all the possible pairs of n balanced parentheses.
    so i have passed the total length as 2n.

  2. close brackt can’t be greater than the open bracket
    becoz β€˜)’ is appending only when it is less than β€˜(’

  3. recursion r working fine
    firstly always open bracket will make call then close bracket will make call becoz of the condition open<close

  4. as we have to generate using n pairs
    so no of left bracket == n

hope this will help u
pls rate my work