Implement a recursive method that returns xn - suppose we


You need to implement a recursive method that returns xn.

Question: Suppose we want methods that compute the value of a double precision number raised to an integer power.

Computing  x^n by repeated multiplication takes n-1 multiplications. We cand o much better using the subsequent fact.

    \(Let p(x, n) = x^{n}\)   

   p(x, n) = {1        if n = 0,

                 {x         if n = 1,

                 {p(x, n/2)^2      if n is even,

                 {x*p(x, n/2)^2    if n is odd (n/2 uses integer division)

Use this fact to prepare a recursive method that computes xn. For efficiency reasons, it is important that each invocation of your method makes/executes only a single recursive call.

Note: computing x100 using repeated multiplication takes 99 multiplications while using the above fact requires only 8!

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Implement a recursive method that returns xn - suppose we
Reference No:- TGS0956253

Expected delivery within 24 Hours