Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following algorithm finds the square root of a positive number: Algorithm squareRoot(number, lowGuess, highGuess, tolerance) newGuess = (lowGuess + highGuess) / 2 if ((highGuess

The following algorithm finds the square root of a positive number:

 Algorithm squareRoot(number, lowGuess, highGuess, tolerance) newGuess = (lowGuess + highGuess) / 2 if ((highGuess - newGuess) / newGuess < tolerance) return newGuess else if (newGuess * newGuess > number) return squareRoot(number, lowGuess, newGuess, tolerance) else if (newGuess * newGuess < number) return squareRoot(number, newGuess, highGuess, tolerance) else return newGuess 

To begin the computation, you need a value lowGuess less than the square root of the number and a value highGuess that is larger. You can use zero as lowGuess and the number itself as highGuess. The parameter tolerance controls the precision of the result independently of the magnitude of number. For example, computing the square root of 250 with tolerance equal to 0.00005 results in 15.81. This result has four digits of accuracy.

Implement this algorithm.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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_2

Step: 3

blur-text-image_3

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

1. Why have benefits grown in strategic importance to employers?

Answered: 1 week ago