Question: Empty C++ code #include using namespace std; int power(int base, int exponent){ // implement the Divide and Conquer-based recursive algorithm here } int main(){ int

Empty C++ code
#include
using namespace std;
int power(int base, int exponent){ // implement the Divide and Conquer-based recursive algorithm here }
int main(){
int base; cout > base; int exponent; cout > exponent;
int result = power(base, exponent);
cout
system("pause");
return 0; }
Design and implement a Divide and Conquer-based (logn) "recursive" algorithm to compute the power function: powerb, n)=b". For example, if base, b= 3 and exponent, n= 16, then power(3, 16) = 346 = 43046721 is to be computed. A brute force approach to compute the power function is simply multiplying the base b to itself (n-1) times, but that would be a (n) algorithm. You are given a startup C++ code that includes a main function (with the base and exponent input by the user and a call is made to the power function) and a power function that needs to be implemented. Submission: Items 1, 2, 3 and 5 in a PDF file Item 4 as a.cpp file (1) A pseudo code of the "recursive" Divide and Conquer-based algorithm to compute the power function. (2) Write the recurrence relation for your algorithm and solve it using Master Theorem (3) Like the illustration of the working of the Factorial problem and other recursive algorithms discussed in class, illustrate the working of your algorithm for base, b= 3 and exponent, n=9. (4) The entire C++ code (5) A screenshot of the output for base, b = 3 and exponent, n=9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
