Answered step by step
Verified Expert Solution
Link Copied!

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Programming With Java A Problem Solving Approach

Authors: John Dean

3rd International Edition

1260575241, 9781260575248

More Books

Students also viewed these Programming questions

Question

What courses does he/she teach?

Answered: 1 week ago

Question

What is object code?

Answered: 1 week ago

Question

In Java, the case of a character does matter. (T / F)

Answered: 1 week ago