1
Data Structures for Disjoint Sets Data Structures for Disjoint Sets
1
S
2
S
3
S
n
S
- {
}
1 2 3
, , , ,
n
S S S S S = …
Collection of disjoint sets Collection of disjoint sets Each set is an Each set is an “ “equiv. Class
- equiv. Class”
” identified by a rep. identified by a rep. Make_Set(x Make_Set(x) ) … … Create the Create the singleton set with singleton set with x x as rep. as rep.
{ }
x
S x =
Find_Set(x Find_Set(x) ) Return pointer to Return pointer to set rep of set rep of Union(x,y Union(x,y) ) … … Create with set rep and Create with set rep and destroy & destroy &
x y
S S ∪
x
S
y
S Data Structures for Disjoint Sets Data Structures for Disjoint Sets
Parameters Parameters
- n
n = # of = # of Make Make-
- Set
Set ops
- ps
- m
m = # of all ops = # of all ops { {Make_Set Make_Set, Union, , Union, Find_Set Find_Set} }
- #
# Unions Unions
- m
n ≥ 1 n ≤ − ≤ − Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets Data Structures for Disjoint Sets