不相交集算法的路径压缩技术的复杂性是什么?

时间:2019-05-21 00:46:24

标签: algorithm disjoint-sets union-find

我正在研究disjoint algorithm with the union by rank and path compression

很明显,如果使用Union by rank,则find() operation的复杂度为O(log(n))

但是我想知道如果我按等级使用联合还是不按等级使用联合,complexity of the path compression technique的不相交集算法是什么?

1 个答案:

答案 0 :(得分:2)

如果您将集合任意地链接在一起,而不是使用按等级的联合或按大小的联合,则仅路径压缩将为 O(m log n)时间实现任意< em> n 联合和 m 查找(其中m> n)。这使得查找操作的摊销成本 O(log n)

证明很难,因此这里提供了很好的确认性参考文献:https://www.cs.princeton.edu/courses/archive/spring13/cos423/lectures/UnionFind.pdf