Question: 4. Consider the two functions below which both compute the value of f(n). The function fi was replaced with f2 because integer multiplications (*)

4. Consider the two functions below which both compute the value of f(n). The function fi was replaced with

4. Consider the two functions below which both compute the value of f(n). The function fi was replaced with f2 because integer multiplications (*) were found to take 4 times longer than integer additions (+). int fi(n: integer) if (n == 1) then return(1) else return(2 fi(n-1)); int f2(n: integer) if (n == 1) then return(1) else return(f2(n-1) + f2(n-1)); i. Give a recurrence relation for f which satisfies the number of multiplications (*) executed as a function of n. ii. Solve the recurrence relation from Part i. iii. Give a recurrence relation for f2 which satisfies the number of additions (+) executed as a function of n. iv. Solve the recurrence relation from Part iii. v. Both functions compute the same function f. Was it a good idea to replace fi with f2?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

i Recurrence Relation for f which satisfies the number of multiplications T Tn 1 1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!