给定N个点,如何找到圆上最多的点?
昨天,我想到了一个有趣的问题,给定 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎有 O(N^3*log N) 算法:)
实际上给定两个点和半径两个圆通常是可能的,但考虑到这一点(将每个组分成 )不会改变算法复杂性。
It seems that there is O(N^3*log N) algorithm :)
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.
除了退化情况外,平面上的任意三点都在圆上。所以一个明显的 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.