Sizes Of The Arguments
void union_sets(int a, int b) {
if (size[a] < size[b]) // line 2
swap(a, b);
a = find_set(a);
b = find_set(b);
if (a != b) {
parent[b] = a;
size[a] += size[b];
}
}
The two optimizations are both present, but line 2 was hoisted above the two find_set calls. Which input makes this version behave measurably worse than the correct one?
Sign in to answer questions and track your progress
Sign In