summaryrefslogtreecommitdiff
path: root/datastructures/unionFind2.cpp
diff options
context:
space:
mode:
authorMZuenni <michi.zuendorf@gmail.com>2023-03-01 11:36:26 +0100
committerMZuenni <michi.zuendorf@gmail.com>2023-03-01 11:36:26 +0100
commit12afe719ce268bb10aa93a910079a44eb08999b8 (patch)
tree0937a117287eebe3942e0506d27143eff4980d09 /datastructures/unionFind2.cpp
parentad8456f7c5d44d3c647b3a368050a5d2f39ae3c3 (diff)
removed trailing whitespaces and use more structured bindings
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));
-}
-
-
+}