Replies: 17 comments 3 replies
-
補充:複雜度分析上,用 而使用 |
Beta Was this translation helpful? Give feedback.
-
最近点对那题 |
Beta Was this translation helpful? Give feedback.
-
kdt重构不应该使用替罪羊树的方法,因为kdt复杂度可以粗略表示为sqrt(2)^dep,而替罪羊树的深度是O(logn)而不是logn,最好的方法是隔约sqrt次操作后重构。当然如果可以离线可以先离线操作建树,这样就避免了插入。 |
Beta Was this translation helpful? Give feedback.
-
替罪羊樹為均攤操作,某一次可能跑比較慢達到整棵樹重建,基本上是不影響整體的需求。而你提供的 sqrt 次操作就重構是局部子樹還是整棵子樹?如果不能保證詢問和插入的數量比例的趨勢,很難給予一個最佳的分析,這可能造成卡在臨界 sqrt 的操作前,不斷地詢問造成單次操作 O(sqrt(n)) |
Beta Was this translation helpful? Give feedback.
-
@morris821028 我的方法是隔 sqrt(n) 次操作重构整棵子树,可以证明总复杂度为 nsqrtnlogn。 |
Beta Was this translation helpful? Give feedback.
-
替罪羊深度最多為 O(log n) 的,而你每 sqrt(n) 才調整一次,那深度應該就會達到 sqrt(n)。套上相同的 kd tree 搜尋邏輯。如果詢問複雜度是深度的一個函數,要做哪一種詢問才會到你所說的單次 sqrt(2)^dep,而每 sqrt(n) 次調整的確不會遇到這個問題? |
Beta Was this translation helpful? Give feedback.
-
这是一个特殊情况,我们在搜索时,除了新加的点外的复杂度最多是 sqrt(n) 的,而访问每个新加的点最多花费 log(n) 的时间,所以新加的点产生的额外搜索时间不会超过 sqrt(n)log(n),总的来说总复杂度也不会超过 sqrt(n)log(n) |
Beta Was this translation helpful? Give feedback.
-
话说我现在也有相同的疑问,为什么l=r的时候return 0也可以哇orz |
Beta Was this translation helpful? Give feedback.
-
似乎可以考虑加入二进制分组等实际复杂度更优的重构策略? |
Beta Was this translation helpful? Give feedback.
-
第三十一行 |
Beta Was this translation helpful? Give feedback.
-
luogu P1429 平面最近点对(加强版)代码貌似写错了吧?build时候 返回0条件应该是l>r, 不是l>=r,OJ上数据水没有测出来 |
Beta Was this translation helpful? Give feedback.
-
话说现在存在有题卡替罪羊重构然后放根号重构麻? |
Beta Was this translation helpful? Give feedback.
-
这个类似替罪羊树的动态加点时间复杂度是假的吧 |
Beta Was this translation helpful? Give feedback.
-
那如果真的把KDT和平衡树结合到一起又会怎么样呢? |
Beta Was this translation helpful? Give feedback.
-
为什么构建k-D Tree时,要轮换使用的轴? You just divide the space by x-axis. But now you have to find those points in the area given by y, such as -1. In this case, the k-D Tree you built thoroughly loses efficacy. Maybe this case is a little extreme, but it could give us one inspiration: If you just build a k-d Tree by one axis, then you lose the infos in the other dimensions. So we need to alternate the splitting dimension by turns. That also makes the value of info of each dimension balanced. But you also could say I just use an x-axis to search. Yeah, in this situation, you certainly could just use x-axis to build the tree. But this obviously makes the k-d tree degenerate to balanced search tree. It's no sense. Please think about the reason you use kd-Tree. |
Beta Was this translation helpful? Give feedback.
-
建树这里好像还可以每次取方差最大的一个维度分割,但是这样不知道会不会有优化(小声 |
Beta Was this translation helpful? Give feedback.
-
https://oi-wiki.org/ds/kdt/
OI Wiki 是一个编程竞赛知识整合站点,提供有趣又实用的编程竞赛知识以及其他有帮助的内容,帮助广大编程竞赛爱好者更快更深入地学习编程竞赛
Beta Was this translation helpful? Give feedback.
All reactions