Algorithms and Data Structures · Middle · Question 34 of 75

What does a union-find (disjoint set) structure support?

Explanation

union(a, b) merges two groups and find(a) returns a group's representative. With path compression and union by rank both are nearly O(1). Typical uses: connected components, Kruskal's MST, "are these accounts the same person?"

Further reading

Problem with a question

Algorithms and Data Structures · Middle · question 34

Test yourself

Take the Algorithms and Data Structures · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz