线性算法在点集中找到具有至少一半直径距离的两个点

Linear algorithm to find two points with at least half diameter distance in a point set

我遇到了以下作业问题:

Consider a point set P in the plane with |P| = n and let D(P) the diameter of P, i.e. the maximum Euclidean distance between any two points in P. I am tasked to find an algorithm of O(n) time that on input of P returns two points x and y of P with d(x,y) >= D(P)/2, where d denotes the Euclidean distance.

我不知道我该怎么做。你能给我一个提示吗?

假设您的积分是 (xi,yi)

  1. 找到 min(xi)O(n) 的点并将其命名为 minX_point
  2. 找到 max(xi)O(n) 的点并将其命名为 maxX_point
  3. 找到 min(yi)O(n) 的点并将其命名为 minX_point
  4. 找到 max(yi)O(n) 的点并将其命名为 maxY_point

现在考虑矩形框这4个点(水平和垂直边缘) 该矩形的直径大于或等于 D(P),因为所有 P 点都包含在其中。 长方形的直径如下 Rec_Diameter=sqrt((minX-maxX)^2+(minY-maxY)^2) 现在找到 max((mixX-maxX),(minY-maxY)) 最大值将是您想要的点,例如 maxX_pointminX_point 因为如果距离小于 D(P)/2 那么我们有 Rec_Diameter=sqrt((minX-maxX)^2+(minY-maxY)^2) < sqrt((D(P)/2)^2+(D(P)/2)^2)=D(P)/sqrt(2) Rec_Diameter>=D(P) < D(P)/sqrt(2) 不正确