Questions: Union-Find (Disjoint Set Union)

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer implements union-find with union by rank but forgets to add path compression. What is the amortized time complexity per operation?

AO(α(n)) — essentially constant, the same as with both optimizations
BO(log n) — better than naive O(n) but worse than using both optimizations together
CO(n) — linear, the same as the naive implementation without any optimization
DO(1) — union by rank alone is sufficient for constant-time performance
Question 2 Multiple Choice

In Kruskal's minimum spanning tree algorithm, union-find is used to evaluate each candidate edge. What specific question does the find operation answer?

AWhether the edge has the minimum weight among all remaining candidate edges
BWhether the two endpoints of the edge are currently in the same connected component
CWhether the edge forms the shortest path between its two endpoints
DWhether the edge's weight exceeds the average weight of edges already added to the tree
Question 3 True / False

Path compression during a find operation changes which element is the representative (root) of the set.

TTrue
FFalse
Question 4 True / False

The near-O(1) amortized time bound for union-find operations requires both path compression and union by rank; either optimization alone gives a weaker guarantee.

TTrue
FFalse
Question 5 Short Answer

Why does path compression speed up future find operations, even though it doesn't change which element is the representative of a set?

Think about your answer, then reveal below.