Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

What is a master budget? An operating budget? A financial budget?

Answered: 1 week ago