xxxxxxxxxx
Time complexity of a recursive function depends on the number of times the
function is calling himself multiply this by the each time how many time
complexity is taken on each call it can be O(1), O(log n), O(n) or more.
Let's say our function is calling n-1 times and each it is doing some
comparisons and call it self again. So function itself has a time complexity of
O(1).
So the total time complexity will be (n-1)*1 which is o(N).
xxxxxxxxxx
void recursiveFun4(int n, int m, int o)
{
if (n <= 0)
{
printf("%d, %d\n",m, o);
}
else
{
recursiveFun4(n-1, m+1, o);
recursiveFun4(n-1, m, o+1);
}
}
Here, it's O(2^n), or exponential, since each function call calls itself twice unless it has been recursed n times.