🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Union-Find (Disjoint Set Union): all 10 questions

Quiz: Union-Find (Disjoint Set Union) · Question 4 of 10

What does union by rank (or size) prevent?

What does union by rank (or size) prevent?

  1. A.Trees growing into long chains, which would make find O(n)
  2. B.Two sets from ever being merged
  3. C.Path compression from working
  4. D.Duplicate elements
Answer & explanation

Correct answer: Trees growing into long chains, which would make find O(n)

Attaching the shorter tree under the taller keeps the height logarithmic even without compression.

Can you get the rest right without peeking?

Take the timed Quiz: Union-Find (Disjoint Set Union) quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →