Question: Rewrite the recursive pow method from Figure 8.11 so that the time to compute pow(x, n) is log(n). FIGURE 8.11 Altemative Implementation of a Method
Rewrite the recursive pow method from Figure 8.11 so that the time to compute pow(x, n) is log(n).

FIGURE 8.11 Altemative Implementation of a Method to Compute Powers Implementation public static double pow(double x, int n) if (x == 0 && n 0) return x * pow(x, n-1); else // x is nonzero, and n is negative. return 1/pow (x, -n); 0) == }
Step by Step Solution
3.50 Rating (160 Votes )
There are 3 Steps involved in it
Java code for an extended version of power functio... View full answer
Get step-by-step solutions from verified subject matter experts
