Question: Work with recursion and Big-O notation This problem considers several ways to compute x^n for integers x and n greaterthanorequalto 0. Write an iterative function
Work with recursion and Big-O notation

This problem considers several ways to compute x^n for integers x and n greaterthanorequalto 0. Write an iterative function power1 to compute x^n for n greaterthanorequalto 0. Write a recursive function power2 to compute x^n by using the following recursive formulation: x^0 = 1 x^n = x * x^n - 1 if n > 0 Write a recursive function power3 to compute x^n by using the following recursive formulation: x^0 = 1 x^n = (x^n/2)^2 if n > 0 and n is even x^n = x * (x^(n - 1)/2)^2 if n > 0 and n is odd Make only one recursive call each time through the function, so that it operates efficiently. 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
