public class UnionFindRemSP extends Object implements IntDisjointSets
| Constructor and Description |
|---|
UnionFindRemSP(int n)
Initializes the disjoint-set data structure.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equivalent(int x,
int y)
Checks if two elements are in the same set.
|
int |
find(int x)
Finds the set of a given element, and compresses the path to the root node.
|
int |
link(int x,
int y)
Unites two given sets.
|
int |
size()
Returns the size of the universe.
|
boolean |
union(int x,
int y)
Unites the sets containing the two given elements.
|
public UnionFindRemSP(int n)
n - the overall size of the domainpublic int size()
IntDisjointSets0 (inclusive) and
size() (exclusive).size in interface IntDisjointSetspublic boolean equivalent(int x,
int y)
IntDisjointSetsequivalent in interface IntDisjointSetsx - the first elementy - the second elementtrue if x and y are in the same set, false otherwisepublic int find(int x)
find in interface IntDisjointSetsx - the elementpublic boolean union(int x,
int y)
union in interface IntDisjointSetsx - the first elementy - the second elementtrue if two disjoint sets have been united as a result, false otherwisepublic int link(int x,
int y)
link in interface IntDisjointSetsx - the first sety - the second setCopyright © 2018. All rights reserved.