Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Partitions

 

Consider the finite universal set tex2html_wrap_inline66651. A partition  of U is a finite set of sets tex2html_wrap_inline66961 with the following properties:

  1. The sets tex2html_wrap_inline59771, tex2html_wrap_inline59801, ..., tex2html_wrap_inline66967 are pairwise disjoint. That is, tex2html_wrap_inline66969 for all values of i and j such that tex2html_wrap_inline66975.
  2. The sets tex2html_wrap_inline59771, tex2html_wrap_inline59801, ..., tex2html_wrap_inline66967 span the universe U. That is,

    eqnarray28107

For example, consider the universe tex2html_wrap_inline66985. There are exactly five partitions of U:

eqnarray28112

In general, given a universe U of size n>0, i.e., |U|=n, there are tex2html_wrap_inline66995 partitions of U, where tex2html_wrap_inline66999 is the so-called Stirling number of the second kind  which denotes the number of ways to partition a set of n elements into m nonempty disjoint subsets.gif

Applications which use partitions typically start with an initial partition and refine that partition either by joining or by splitting elements of the partition according to some application-specific criterion. The result of such a computation is the partition obtained when no more elements can be split or joined.

In this chapter we shall consider only applications that begin with the initial partition of U in which each item in U is in a separate element of the partition. Thus, the initial partition consists of |U| sets, each of size one (like tex2html_wrap_inline67015 above). Furthermore, we restrict the applications in that we only allow elements of a partition to be joined--we do not allow elements to split.

The two operations to be performed on partitions are:

find
Given an item in the universe, say tex2html_wrap_inline67017, find the element of the partition that contains i. That is, find tex2html_wrap_inline67021 such that tex2html_wrap_inline67023.
join
Given two distinct elements of a partition P, say tex2html_wrap_inline67027 and tex2html_wrap_inline67021 such that tex2html_wrap_inline61295, create a new partition P' by removing the two elements tex2html_wrap_inline67035 and tex2html_wrap_inline67037 from P and replacing them with a single element tex2html_wrap_inline67041.

For example, consider the partition tex2html_wrap_inline67043. The result of the operation tex2html_wrap_inline67045 is the set tex2html_wrap_inline67047 because 3 is a member of tex2html_wrap_inline59801. Furthermore, when we join sets tex2html_wrap_inline59771 and tex2html_wrap_inline59803, we get the partition tex2html_wrap_inline67057.




next up previous index

Bruno Copyright © 2003, 2004 by Bruno R. Preiss, P.Eng. All rights reserved.