Question: Write a recursive method static int intSquareRoot(int n) {} // return the biggest number whose square is = 0. Use recursion. No loops allowed. You
Write a recursive method
static int intSquareRoot(int n) {} // return the biggest number whose square is <= n. Assume n >= 0.
Use recursion. No loops allowed. You will need to recurse on n/4 rather than n-1. That's because the method is called with some big values. If you recurse on n-1 those values will generate a StackOverflowError.
Of course Math.sqrt() or other Math class methods are not to be used in your implementation. You're just coding this using recursion and elementary operations.
Implementation Hint: intSquareRoot(n) is close to intSquareRoot(n/4) * 2. (Either equal to it or one more than it. You can tell which one, by squaring something.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
