【发布时间】:2016-03-14 16:19:45
【问题描述】:
在Computational Geometry: Algorithms and Applications by Mark de Berg 中可以找到以下binary space partitioning 算法:
BSP(Finite set of finite non-intersecting line segments S)
{
if (n > 1)
{
Use the extension of the first segment in S as the splitting line L
Let S+ and S- be the set of fragments above and below L, respectively
Create a tree T with left subtree = BSP(S-) and right subtree BSP(S+)
Store all segments which overlap with L in T
}
else
Create a tree T and store S in T
return T
}
如果分割线L将一个片段分成两半,则生成一个片段。您可能想查看another question of me where I give an example for this process。
We can show 表示BSP 生成的片段的预期数量最多为n + 2n log(n),如果这些片段是随机打乱的(这样这些片段的每个可能的排列都有相同的出现概率)并且n 表示段数。
我们如何限制预期的递归调用次数?
在 de Berg 的书中,作者指出,递归调用的预期数量受生成片段的预期数量的限制。 为什么?
显然,一条分割线L最多可以产生n - 1新片段。在最坏的情况下,所有这些新片段都位于L 的一侧。在这种情况下,S+ 和S- 中的每一个都将包含n - 1 元素。因此,我们将有两个递归调用,输入大小为n - 1。这导致T(n) = n - 1 + 2 * T(n - 1) 的递归运行时间。 [n - 1 因为这是我们需要测试它们是否高于或低于L 的元素的数量。
我们可以展开递归,但我认为这会产生非常糟糕的估计。那么,我们需要怎么做呢?我们如何利用已知的预期生成片段数?
【问题讨论】:
标签: algorithm 3d time-complexity computer-science computational-geometry