🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. In Union-Find, two elements are in the same set exactly when:
  2. Q2. What does this print? (code)
  3. Q3. What does path compression do?
  4. Q4. What does union by rank (or size) prevent?
  5. Q5. With both path compression and union by rank, the cost of one operation is:
  6. Q6. How do you count connected components with DSU?
  7. Q7. What does this print? (code)
  8. Q8. Which task can Union-Find NOT do on its own?
  9. Q9. Why is an iterative find often preferred over a recursive one in Java or Python for n = 10⁶?
  10. Q10. In Kruskal's algorithm, what does a union that returns False tell you?