← All topics
Quiz: Union-Find (Disjoint Set Union): questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. In Union-Find, two elements are in the same set exactly when:
- Q2. What does this print? (code)
- Q3. What does path compression do?
- Q4. What does union by rank (or size) prevent?
- Q5. With both path compression and union by rank, the cost of one operation is:
- Q6. How do you count connected components with DSU?
- Q7. What does this print? (code)
- Q8. Which task can Union-Find NOT do on its own?
- Q9. Why is an iterative find often preferred over a recursive one in Java or Python for n = 10⁶?
- Q10. In Kruskal's algorithm, what does a union that returns False tell you?