Members
forest
Set<Tree>
map
Map<string, Tree>
makeSet
void
Initializes x as a lone node.
@complexity
Θ(1) in the worst case
@paramx
string
@returns
void
findSet
Tree
@paramx
string | Tree
@returns
Tree
union
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
Tree
merge
Tree
Merging 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