Click or drag to resize
FarthestPair Class

The FarthestPair data type computes the farthest pair of points in a set of N points in the plane and provides accessor methods for getting the farthest pair of points and the distance between them. The distance between two points is their Euclidean distance.

This implementation computes the convex hull of the set of points and uses the rotating calipers method to find all antipodal point pairs and the farthest pair. It runs in O(N log N) time in the worst case and uses O(N) extra space. See also and .

Inheritance Hierarchy
SystemObject
  Algs4NetFarthestPair

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class FarthestPair

The FarthestPair type exposes the following members.

Constructors
  NameDescription
Public methodFarthestPair
Computes the farthest pair of points in the specified array of points.
Top
Properties
  NameDescription
Public propertyEither
Returns one of the points in the closest pair of points.
Public propertyOther
Returns the other point in the closest pair of points.
Top
Methods
  NameDescription
Public methodDistance
Returns the Eucliden distance between the closest pair of points. This quantity is also known as the Diameter of the set of points.
Public methodStatic memberMainTest
Demo test the FarthestPair data type. Reads in an integer N and N points (specified by their X- and Y-coordinates) from standard input; computes a farthest pair of points; and prints the pair to standard output.
Top
Remarks

For additional documentation, see Section 9.9 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class FarthestPair implementation by the respective authors.

See Also