Question: Q1) (20 points) let C(n) = 1 + 2 +3+...+n be the sum of the first n cubes. a) Write a recursive algorithm to compute

Q1) (20 points) let C(n) = 1 + 2 +3+...+n be the sum of the first n cubes. a) Write a recursive algorithm to compute C(n). b) What is the recurrence relation for your algorithm? c) What is the time complexity of the algorithm you developed? Q2) (20 points) Consider the following algorithm Algorithm XYZ (r,q,n) \ ,q,n are positive integers 1. if n = 1 then returns 2. else 3. if nis odd then return XYZ(r,q,n - 1) + (n - 1) 4. else return XYZ(r,q,n-1)-(n-1) a) What does the algorithm compute? b) What is the recurrence relation for the algorithm? c) What is the time complexity of the algorithm (solve the recurrence in part b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
