Implementation
ID find(Object x) {
assert(hTable.contains(x));
ID xID = hTable[x];
while(up[xID] != -1) {
xID = up[xID];
}
return xID;
}
ID union(ID x, ID y) {
assert(up[x] == -1);
assert(up[y] == -1);
up[y] = x;
}
typedef ID int;
runtime: O(depth) or …
runtime: O(1)
Previous slide
Next slide
Back to first slide
View graphic version