Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. import java.util.Scanner; 2. public class root 3. { 4. public static void main(String[] args) 5. { 6. 7. 8. Scanner input= new Scanner(System.in);
1. import java.util.Scanner; 2. public class root 3. { 4. public static void main(String[] args) 5. { 6. 7. 8. Scanner input= new Scanner(System.in); double number = input.nextDouble(); double a = 2; while (Math.abs(a-(number/a))>=0.25) { a = (a+(number/a))/2; 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. System.out.println((int) a); 20. } 21.} Select one: } a = Math.floor(a); number = a; a = 2; while (Math.abs(a-(number/a))>=0.25) { a = (a+(number/a))/2; } a = Math.floor(a); In Big O notation, what is the run-time of this algorithm as a function of the input n? a. O(log n) O b. 0(1) O c. O(log n) + O(log n) O d. O(n) e. O(2 log n)
Step by Step Solution
★★★★★
3.37 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
The algorithm provided is an implementation of the Newtons method ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started