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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post by answerhappygod »

4 Consider The Two Functions Below Which Both Compute The Value Of F N The Function Fi Was Replaced With F2 Because I 1
4 Consider The Two Functions Below Which Both Compute The Value Of F N The Function Fi Was Replaced With F2 Because I 1 (62.99 KiB) Viewed 50 times
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) int f2(n: integer) if (n == 1) then return(1) if (n == 1) then return(1) else return(2 * fi(n-1)); else return(12(n − 1) + f2(n − 1)); i. Give a recurrence relation for fi 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 f1 with f2?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply