Question: 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
The algorithm provided is an implementation of the Newtons method ... View full answer
Get step-by-step solutions from verified subject matter experts
