Question: Problem 5. (50 POINTS) For this problem you are allowed to add, multiply, shift or compare numbers in unit time (i.e. (1) time); you are
Problem 5. (50 POINTS) For this problem you are allowed to add, multiply, shift or compare numbers in unit time (i.e. (1) time); you are not allowed to use operations such as . We are given an integer n and we are interested in determining whether n is a perfect square i.e. whether there exists another integer m such that m2=n. One way to solve this problem is to try all the numbers between 1 and about n (if you know how to find an approximation of the square root using the allowable operations) for m, an algorithm that requires O(n) time. This is too slow. Can you solve this problem faster than (n) time? Explain by providing an efficient algorithm that solves this problem. Analyze its worst-case running time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
