Generate parantheses

i understood backtracking and how if N=3 this can be created ()()(); but i didnt understood how code is generating other forms like ((())) etc.

by checking every if conditions each time it backtracks,like when openB=3=closeB, it goes to openB=3,closeB=2 and in this state,it can neither append ‘(’ nor ‘)’ so it simply pop out the bracket…

But when it comes to state when openB=2,closeB=1 , 2nd if condition i.e (openB<n) satisfies and ‘(’ will be appended… and the form becomes ()(( and then we’ll have to check for openB=2,closeB=2.