
EE 360C — Algorithms Spring 2007
Data Structures for Disjoint Sets
Adnan Aziz UT Austin
Based on CLRS, Ch 21.
In several applications, need to group ndistinct elements into a collection of disjoint sets.
•Example — electrically equivalent nets on a PCB
Operations:
•return which set an element belongs to
•form the union of sets corresponding to two elements
Formally: disjoint set data structure maintains a collection S={S1, S2, . . . , Sk}of disjoint dy-
namic sets
•identify each set by a “representative” member
–usually don’t care which one is representative; just want it to remain the same if no
operations are performed on the set
Let x, y be elements; want to support the following operations:
1. MAKE-SET(x)— return a new set whose only member is x
•very important: xbetter not be present in any other current set — our assumption is
that we are working with disjoint sets
2. FIND-SET(x)— returns a pointer to representative of set containing x
3. UNION(x, y)— unites sets containing xand y
Want efficient algorithms
•will measure runtimes of operations in terms of
–n— the number of make-set operations, and
1