Only Two Entries Change
This DSU forest has no path compression yet. The arrow on each node points to its parent, and parent[0] = 0.
Now one call runs:
int find_set(int v) {
if (v == parent[v])
return v;
return parent[v] = find_set(parent[v]);
}
find_set(7);
After it returns, how many entries of the parent array hold a different value than before?
Sign in to answer questions and track your progress
Sign In