18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Generating Partitions<br />

Set partitions can be generated using techniques similar to integer partitions. Each set partition is<br />

encoded as a restricted growth function, , where and , for<br />

. Each distinct digit identifies a subset, or block, of the partition, while the growth condition<br />

ensures that the blocks are sorted into a canonical order based on the smallest element in each block. For<br />

example, the restricted growth function 0,1,1,2,0,3,1 defines the set partition {{1,5}, {2,3,7}, {4}, {6} }.<br />

Since there is a one-to-one equivalence between set partitions and restricted growth functions, we can use<br />

lexicographic order on the restricted growth functions to order the set partitions. Indeed, the fifteen<br />

partitions of {1,2,3,4} listed above are sequenced according to the lexicographic order of their restricted<br />

growth function (check it out).<br />

To randomly generate set partitions, we use a similar counting strategy as with integer partitions. <strong>The</strong><br />

Stirling numbers of the second kind S(n,k) count the number of partitions of 1,...,n with exactly k blocks.<br />

<strong>The</strong>y are computed using the recurrence S(n,k) = S(n-1,k-1) + k*S(n-1,k) with the boundary conditions<br />

S(n,n)=1. <strong>The</strong> reader is referred to the references and implementations for more details and code.<br />

Implementations: <strong>The</strong> best source on generating combinatorial objects is Nijenhuis and Wilf [NW78],<br />

who provide efficient Fortran implementations of algorithms to construct random and sequential integer<br />

partitions, set partitions, compositions, and Young tableaux. See Section for details on ftp-ing these<br />

programs.<br />

An exciting WWW site developed by Frank Ruskey of the University of Victoria contains a wealth of<br />

material on generating combinatorial objects of different types, including permutations, subsets,<br />

partitions, and certain graphs. It is well worth checking this out at http://sue.csc.uvic.ca/~cos/.<br />

Combinatorica [Ski90] provides Mathematica implementations of algorithms to construct random and<br />

sequential integer partitions, compositions, strings, and Young tableaux, as well as to count and<br />

manipulate these objects. See Section .<br />

<strong>Algorithm</strong> 403 [BL77] of the Collected <strong>Algorithm</strong>s of the ACM is a Fortran code for constructing integer<br />

partitions with k parts. It is available from Netlib (see Section ). <strong>The</strong> Stanford GraphBase (see<br />

Section ) also contains generators for constructing all integer partitions.<br />

Notes: <strong>The</strong> standard references on combinatorial generation [NW78, RND77, Rus97] all present<br />

algorithms for generating integer and/or set partitions. Andrews is the primary reference on integer<br />

partitions and related topics.<br />

Interestingly, the set of all 52 set partitions for n=5 appears in the form of Murasaki diagrams in the oldest<br />

novel known, <strong>The</strong> Tale of Genji.<br />

file:///E|/BOOK/BOOK4/NODE153.HTM (3 of 4) [19/1/2003 1:30:46]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!