最接近的点对 平面情况

发布于 2024-11-03 07:16:39 字数 396 浏览 4 评论 0原文

我正在查看维基百科条目以了解如何解决此问题。它列出了五个步骤

1.沿 x 坐标对点进行排序

2.通过垂直线 x = xmid 将点集分成两个大小相等的子集

3.在左右子集中递归地解决问题。这将分别给出左侧和右侧最小距离 dLmin 和 dRmin。

4. 求一对点之间的最小距离 dLRmin,其中一个点位于分割垂线的左侧,第二个点位于分割垂线的右侧。

5.最终答案为dLmin、dRmin、dLRmin中的最小值。

第四步我有点难以理解。如何选择线左侧的点与线右侧的点进行比较。我知道我不应该比较所有点,但我不清楚如何选择要比较的点。请不要给我发送链接,我已经搜索过,访问过很多链接,但没有找到可以帮助我理解步骤 4 的解释。

谢谢

Aaron

I am looking at the wikipedia entry for how to solve this. It lists five steps

1.Sort points along the x-coordinate

2.Split the set of points into two equal-sized subsets by a vertical line x = xmid

3.Solve the problem recursively in the left and right subsets. This will give the left-side and right-side minimal distances dLmin and dRmin respectively.

4.Find the minimal distance dLRmin among the pair of points in which one point lies on the left of the dividing vertical and the second point lies to the right.

5.The final answer is the minimum among dLmin, dRmin, and dLRmin.

The fourth step I am having trouble understanding. How do I choose what point to the left of the line to compare to a point right of the line. I know I am not supposed to compare all points, but I am unclear about how to choose points to compare. Please do not send me a link, I have searched, gone to numerous links, and have not found an explanation that helps me understand step 4.

Thanks

Aaron

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栀梦 2024-11-10 07:16:39

您的问题的答案在维基百科文章的下一段中:

事实证明,第4步可能是
在线性时间内完成。再次,一个
天真的方法需要
计算所有距离
左右对,即二次
时间。关键观察基于
的以下稀疏性质
点集。我们已经知道
最近的点对不再是
除了 dist = min(dLmin,dRmin) 之外。
因此对于左边的每个点p
的分界线,我们必须
比较点的距离
位于矩形中
尺寸 (dist, 2 * dist) 到
分割线右侧,如图
图中。而且更重要的是,这个
矩形最多可以包含 6 个点
至少具有成对距离
dR 分钟。因此,足以
最多计算 6n 个左右
步骤 4 中的距离。递归
步数的关系可以
写为 T(n) = 2T(n / 2) + O(n),
我们可以使用大师来解决
定理得到 O(n log n)。

我认为我无法比他们已经说得更清楚了,但是您对算法的这一步有任何具体问题吗?

The answer to your question was in the next paragraph of the wikipedia article:

It turns out that step 4 may be
accomplished in linear time. Again, a
naive approach would require the
calculation of distances for all
left-right pairs, i.e., in quadratic
time. The key observation is based on
the following sparsity property of the
point set. We already know that the
closest pair of points is no further
apart than dist = min(dLmin,dRmin).
Therefore for each point p of the left
of the dividing line we have to
compare the distances to the points
that lie in the rectangle of
dimensions (dist, 2 * dist) to the
right of the dividing line, as shown
in the figure. And what is more, this
rectangle can contain at most 6 points
with pairwise distances at least
dRmin. Therefore it is sufficient to
compute at most 6n left-right
distances in step 4. The recurrence
relation for the number of steps can
be written as T(n) = 2T(n / 2) + O(n),
which we can solve using the master
theorem to get O(n log n).

I don't think I can put it much clearer than they already have, but do you have any specific questions about this step of the algorithm?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文