Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The documentation for the computer language Java recommends that when an \"equal

ID: 3821414 • Letter: T

Question

The documentation for the computer language Java recommends that when an "equals method" is defined for an object, it be an equivalence relation. That is, if R is defined as follows: xRy x. equals(y) for all objects in the class, then R should be an equivalence relation. Suppose that in trying to optimize some of the mathematics of a graphics application, a programmer creates an object called a point, consisting of two coordinates in the plane. The programmer defines an equals method as follows: if p and q are any points, then p. equals(q) the distance from p to q is less than or equal to c, where c is a small positive number that depends on the resolutions of the computer display. Is this programmer's equals method an equivalence relation? Justify your answer.

Explanation / Answer

equals method will be an equivalence method if it holds:
   reflexive, symmetric and transitive property.

The given programmer's equal methos is not equivalence relation

It does not hold transitive property:

   p1.equals(p2) => distance(p1, p2) <= c
   p2.equals(p3) => distance(p2, p3) <= c

   Then it is not ncecessary that : p1.equals(p3) => distance(p1, p3) <= c

   p1----(d1 <= c)------p2-------(d2 <= c)-------p3

   clearly (d1 + d2) can be greater than c

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote