void solve(string op, int n, int zeros, int ones)
{
if(n==0){
cout<<op<<" ";
return;
}
string op1 = op;
op1.push_back('1');
solve(op1, n-1, zeros, ones+1);
if(ones > zeros){
string op2 = op;
op2.push_back('0');
solve(op2, n-1, zeros+1, ones);
return;
}
}
what is the time complexity for the solve function? is it O(2^N)? can someone please explain how you approach to find complexities for recursive functions?
link to question: Print N-bit binary numbers having more 1’s than 0’s in all prefixes - GeeksforGeeks