Union Without The Find
int parent[N];
int find_set(int v) {
if (v == parent[v]) return v;
return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
parent[a] = b; // line 9
}
Starting from make_set on 0..3, the calls union_sets(0, 1), union_sets(2, 3), union_sets(0, 2) run in that order. What does find_set(1) return afterwards, and what has gone wrong?
Sign in to answer questions and track your progress
Sign In