Skip to content

The disjoint Sets Class

Union-by-Size

change size when union

Union-by-Height

does not need to change height when union, tree height only changes when two trees are of the same size,

find is dynamic, let the found node points directly to the root node. However, we need to change the height.

Union-by-Rank

After find(), we do not change the height. So the height bacomes the rank.

Generate Maze