Question: This problem considers several ways to compute x for integers x and n 20. a. Write an iterative function power 1 to computex for n

This problem considers several ways to compute x" for integers x and n 20. a. Write an iterative function power 1 to computex" for n 20. b. Write a recursive function power2 to computex" by using the following recursive formulation: x =1 x"=x*xn-1 ifn> 0 c. Write a recursive function power to compute x" by using the following recursive formulation: x0=1 x1 = (x/2)2 if n >0 and n is even x = x (x(n-1)/2,2 ifn >0 and n is odd Make only one recursive call each time through the function, so that it operates efficiently. d. What is the running time of each of the above algorithms as function of n? Use Big-O notation and justify your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
