English

If 2 = 1.414, and the square_root() function returns -1.414, does it violate the following specification? -- square_root (x) -- inputs: x is a real number , x ≥ 0 -- outputs: y is a real number

Advertisements

Question

If `sqrt2` = 1.414, and the square_root() function returns -1.414, does it violate the following specification?

-- square_root (x)
-- inputs: x is a real number , x ≥ 0
-- outputs: y is a real number such that y2 = x

One Line Answer
Advertisements

Solution

No, because (- 1.414)2 = 2, which satisfies input – output relation (y2 = x)

shaalaa.com
Algorithmic Problems
  Is there an error in this question or solution?
Chapter 6: Specification and Abstraction - Evaluation - Section - B [Page 86]
Advertisements
Share
Notifications



      Forgot password?
Use app×