From 12afe719ce268bb10aa93a910079a44eb08999b8 Mon Sep 17 00:00:00 2001 From: MZuenni Date: Wed, 1 Mar 2023 11:36:26 +0100 Subject: removed trailing whitespaces and use more structured bindings --- datastructures/unionFind2.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'datastructures/unionFind2.cpp') 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)); -} - - +} -- cgit v1.2.3