Question
1. Solve the following recurrence relation using iterative substitution: T(0) = c2 T(n)=c1 +n+T(n-1) for n>0 2. Consider this function, and then answer the questions
1. Solve the following recurrence relation using iterative substitution: T(0) = c2 T(n)=c1 +n+T(n-1) for n>0
2.
Consider this function, and then answer the questions that follow. (For the sake of simplicity, dont worry about issues with integer overflow here.)
int floofy(int n) {
if (n < 1) return n * 2;
return floofy(n-1) * floofy(n-1); }
(a) Using Big-Oh notation, what is the runtime of this function? (You dont have to justify your answer.)
(b) What slight modification can you make to the code above to drastically reduce its runtime? (Re-write the function in the space above with your modification. Dont change it to an iterative function, though! Keep it recursive.)
(c) Using Big-Oh notation, what is the runtime of the function using the modification you proposed in part (b)? (Again, you dont have to justify your answer.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started