How would I trace the steps for the function's output?
int f(int n)
{
if (n==0)
return 1;
else if(n==1)
return 2;
else
return 2* f(n-2) + f(n-1);
}
Would it be something like:
(Let's say n=6)
step 1) 2 * f(6-2) + f(6-1)
2) 2 * f(4-2) + f(5-1)
3) 2 * f(2-1) + f(4-1)
4) 2 * f(1-1) + f(3-1)
Then stop after step 4 since it reached the base case and then return it from step 4 to 1?