Union-Find (Disjoint-Set Union) Quiz

Q1. What does **path compression** do during a `find(x)` call?




Q2. With both path compression and union-by-rank/size enabled, what is the amortized time per `find` or `union` operation?




Q3. In **union-by-rank**, when the two roots have **different** ranks, which root becomes the parent?




Q4. When do you increment the rank of a root in union-by-rank?




Q5. Which auxiliary array lets you answer **“how many elements are in this set?”** in O(1) time?




Q6. Without any optimizations (no rank/size, no path compression), what is the worst-case time complexity of `find(x)`?




Q7. Which union policy is **most likely** to create a deep chain and hurt performance?




Q8. In **union-by-size**, if set A has 3 elements and set B has 5 elements, which root becomes the new parent after `union(A, B)`?




Q9. After calling `find(x)` with path compression on a deep node, what happens to that node’s `parent` pointer?




Q10. Which combination of heuristics is required to achieve the classic **α(n) amortized** performance bound?




data-structures-and-algorithms