Members
forest
Set<Tree>map
Map<string, Tree>makeSet
voidInitializes x as a lone node.
@complexity
Θ(1) in the worst case@paramx
string@returns
voidfindSet
Tree@paramx
string | Tree@returns
Treeunion
Tree- Climbs to the roots of the trees containing x and y
- and merges parents sets
rep[y],rep[x].
@complexity
Θ(height)@paramx
string | Tree@paramy
string | Tree@returns
Treemerge
TreeMerging the tree with the smaller height into the tree with the bigger height
- the height of a tree remains O(lg n).
@paramx
Tree@paramy
Tree@returns
Tree