Answers for "Time complexity in recursion"

0

Time complexity in recursion

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.
Posted by: Guest on July-18-2021

Code answers related to "Time complexity in recursion"

Browse Popular Code Answers by Language