Question: 1. What is the complexity of void doit(int n) { if (n <1) return; for (int i=0; i < n ; i++) x++; doit(n-1); }
1. What is the complexity of
void doit(int n)
{
if (n <1) return;
for (int i=0; i < n ; i++)
x++;
doit(n-1);
}
List the values of a, b, k
2. What is the complexity of
void doit(int n)
{
if (n <1) return;
for (int i=0; i < n ; i++)
x++;
doit(n-1);
doit(n-1);
}
List the values of a, b, k
a =number of calls at each level.
b = how the size is divided between calls.
k = the amount of work as an exponent
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
