Time complexity of indirect recursion

494 Views Asked by At

How to find the complexity of an the given algorithm:

Algorithm f(int n)

{

if(n==1)return(1);

else
{
  f(n-1)+g(n-1);
}

}

Algorithm g(int n)

{

if(n==2)return(1);
else
{
  f(n-1)+g(n/2);
}

}

The answer is O(2^n), But how?

1

There are 1 best solutions below

0
On

Set up two variables (for $f$ and $g$) and define a system of recurrences.