给定N个点,如何找到圆上最多的点?

发布于 2024-11-01 08:50:25 字数 94 浏览 1 评论 0原文

昨天,我想到了一个有趣的问题,给定 N 个点,如何找到一个圆上的最大点数?

除了暴力破解之外,您还能提出其他建议吗?什么是O(?)?

Yesterday, an interesting question comes to mind, Given N points, how do you find the maximum number of points that are on a circle?

Can you suggest anything other than brute-force? What is O(?)?

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

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

发布评论

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

评论(2

趁年轻赶紧闹 2024-11-08 08:50:25

似乎有 O(N^3*log N) 算法:)

iterate through all pairs of points - O(N^2)
    for each point of the rest compute radius of circle including that point and the selected pair of points - O(N)
    sort points by this radius - O(N*log N)
    select from the resulting array the biggest group with same radius - O(N)

实际上给定两个点和半径两个圆通常是可能的,但考虑到这一点(将每个组分成 )不会改变算法复杂性。

It seems that there is O(N^3*log N) algorithm :)

iterate through all pairs of points - O(N^2)
    for each point of the rest compute radius of circle including that point and the selected pair of points - O(N)
    sort points by this radius - O(N*log N)
    select from the resulting array the biggest group with same radius - O(N)

Actually given two points and radius two circles are generally possible, but taking this into account (splitting each group into to) will not change algorithm complexity.

口干舌燥 2024-11-08 08:50:25

除了退化情况外,平面上的任意三点都在圆上。所以一个明显的 O(n4) 算法就是枚举所有不在一条直线上的三个点的集合 (O(n3)),计算出线的中心圆(也许可以有两个,我不确定)遍历这三个点,然后迭代其他点并检查哪些点在同一个圆上,计数,并在算法完成后报告最大值。

Except for degenerate cases, any three points on a plane are on a circle. So an obvious O(n4) algorithm is to enumerate all sets of three points that are not on a line (O(n3)), calculate the center of the circle (maybe there can be two, I'm not sure) going through the three points, and then iterate through the other points and check which ones are on the same circle, count, and after algorithm has finished, report the maximum.

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