I need to find an upper limit for the runtime of $f(n)$.
f(n):
{
g(n,1)
}
g(n,k):
{
if n<=0 return;
for(i=1; i<=n; i++)
{
print "I love data structures!";
k++;
g(n-1, k);
}
return;
}
I tried to think of it this way:
for(i=1; i<=n; i++)
$\rightarrow (n+1)c_2$
g(n-1, k)
$\rightarrow ng(n-1)$
$$f(n) = g(n,1) + c_f = c_1 + (n+1)c_2 + nc_3 + nc_4 + ng(n-1) + c_f$$
I am not sure about the recursion runtime analysis:
g(n-1,k)
$\rightarrow ng(n-1)$
Thank you!