union-find problem

quick-find algorithm

Represents a component of the same identifier; all contacts when union, in which a node is located points to another component of the component
time complexity of O ($ N ^ 2 $)

quick-union algorithm

Forest defined, find root; root if the same is not operating; different if the root node, the root node points to another one root
time complexity of O ($ N ^ 2 $)

Weighted qucikunion algorithm

The small tree is always linked to a large tree
time complexity O ($ logN $)

Path compression (optimal algorithm)

In looking for the root node, while the node is directly connected to the root node of the tree of degree 2

Guess you like

Origin www.cnblogs.com/endevelop-gw/p/12508070.html