avatar
w*5
2
一个平面上n个点,需要两两配对,但有个constraint是距离不能大于k,这样有些点可
能最后无法被配对。有没有算法使得能配对的点最多?
follow-up是求出最小的k,使得所有点都能配上对。
这个应该怎么考虑?
avatar
H*1
3
G(V,E) where |V| = n as points, E = {(u,v)| dist(u,v) <= k}
Now what you are looking at are matchings, so just apply Edmonds' algorithm.
O(\sqrt(V) * E). Since the G is a unit disk graph here, you may be able to
improve the algorithm, google or wait till DaNiu post an answer.
For finding the smallest k, there are probably smarter ways, but a 糙快猛
practical solution could be:
Find d = closest pair distance O(nlgn)
Find D = farthest pair distance O(nlgn)
Binary Search on [d, D] O(lg(D-d) * \sqrt(V) * E) until you find the k
avatar
w*5
4
多谢大牛

algorithm.

【在 H*******1 的大作中提到】
: G(V,E) where |V| = n as points, E = {(u,v)| dist(u,v) <= k}
: Now what you are looking at are matchings, so just apply Edmonds' algorithm.
: O(\sqrt(V) * E). Since the G is a unit disk graph here, you may be able to
: improve the algorithm, google or wait till DaNiu post an answer.
: For finding the smallest k, there are probably smarter ways, but a 糙快猛
: practical solution could be:
: Find d = closest pair distance O(nlgn)
: Find D = farthest pair distance O(nlgn)
: Binary Search on [d, D] O(lg(D-d) * \sqrt(V) * E) until you find the k

avatar
l*n
5
这是哪儿的面试题?
还是课程作业

【在 w********5 的大作中提到】
: 一个平面上n个点,需要两两配对,但有个constraint是距离不能大于k,这样有些点可
: 能最后无法被配对。有没有算法使得能配对的点最多?
: follow-up是求出最小的k,使得所有点都能配上对。
: 这个应该怎么考虑?

avatar
b*m
6
奇数个点,多大的k也不行呀。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。