summaryrefslogtreecommitdiff
path: root/datastructures/unionFind2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'datastructures/unionFind2.cpp')
-rw-r--r--datastructures/unionFind2.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/datastructures/unionFind2.cpp b/datastructures/unionFind2.cpp
index 225ecee..b86c8e0 100644
--- a/datastructures/unionFind2.cpp
+++ b/datastructures/unionFind2.cpp
@@ -11,17 +11,15 @@ int findSet(int i) {
}
void linkSets(int i, int j) {
- //Take |uf[i]|, where i must be a root, to get the size
+ //Take |uf[i]|, where i must be a root, to get the size
//of the subset
if(abs(uf[i]) < abs(uf[j])) { //Union-by-size.
- uf[j] += uf[i]; uf[i] = j;
+ uf[j] += uf[i]; uf[i] = j;
} else {
- uf[i] += uf[j]; uf[j] = i;
+ uf[i] += uf[j]; uf[j] = i;
}
}
void unionSets(int i, int j) {
if(findSet(i) != findSet(j)) linkSets(findSet(i),findSet(j));
-}
-
-
+}