
ECS122A Handout May 21, 2009
Apriority queue is a data structure for maintaining a set Sof elements, each with an
associated value called a key. There are max-priority queue and min-priority queue,
supporting the following operations:
•Insert(S, x): inserts the element xinto the set S
S←S∪ {x}
•Delete(S, x): deletes the element xfrom the set S
S←S− {x}
•Maximum(S): returns x∈Swith largest key
•Minimum(S): returns x∈Swith smallest key
•Search(S, k): returns x∈Swith key[x] = k
•Extract-max(S): removes and returns x∈Swith largest key
•Extract-min(S): removes and returns x∈Swith smallest key
•Increase-key(S, x, k): increases the value of element x’s key to the new value k, which
is assumed to be at least as large as x’s current key value.
•Decrease-key(S, x, k): decreases value of element x’s key to the new value k, which is
assumed to be at least as small as x’s current key value.
Adisjoint-set data structure maintains a collection of S={S1, S2,...,Sk}of disjoint
dynamic sets. Each set is identified by a representative, which is some member of the set. A
disjoint-set data structure supports the following operations:
•Make-set(x): creates a new set whose only member (and thus representative) is x.
•Union(x, y): unites the sets that contain xand y, say Sxand Sy, into a new set that is
the union of these two sets: Sx∪Sy. The representative is any member of Sx∪Sy.
•Find-set(x): returns (a pointer to) the representative of the (unique) set containing x.
1