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

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

18.04.2013 Views

Generating Permutations Such subtleties demonstrate why you must be very careful with random generation algorithms. Indeed, we recommend that you try some reasonably extensive experiments with any random generator before really believing it. For example, generate 10,000 random permutations of length 4 and see whether all 24 of them occur approximately the same number of times. If you understand how to measure statistical significance, you are in even better shape. Implementations: The best source on generating combinatorial objects is Nijenhuis and Wilf [NW78], who provide efficient Fortran implementations of algorithms to construct random permutations and to sequence permutations in minimum-change order. Also included are routines to extract the cycle structure of a permutation. See Section for details. An exciting WWW site developed by Frank Ruskey of the University of Victoria contains a wealth of material on generating combinatorial objects of different types, including permutations, subsets, partitions, and certain graphs. Specifically, there is an interactive interface that lets you specify which type of objects you would like to construct and quickly returns the objects to you. It is well worth checking this out at http://sue.csc.uvic.ca/ cos/. Combinatorica [Ski90] provides Mathematica implementations of algorithms that construct random permutations and sequence permutations in minimum change and lexicographic orders. It also provides a backracking routine to construct all distinct permutations of a multiset, and it supports various permutation group operations. See Section . The Stanford GraphBase (see Section ) contains routines to generate all permutations of a multiset. Notes: The primary reference on permutation generation is the survey paper by Sedgewick [Sed77]. Good expositions include [NW78, RND77, Rus97]. The fast permutation generation methods make only a single swap between successive permutations. The Johnson-Trotter algorithm [Joh63, Tro62] satisfies an even stronger condition, namely that the two elements being swapped are always adjacent. In the days before ready access to computers, books with tables of random permutations [MO63] were used instead of algorithms. The swap-based random permutation algorithm presented above was first described in [MO63]. Related Problems: Random number generation (see page ), generating subsets (see page ), file:///E|/BOOK/BOOK4/NODE151.HTM (4 of 5) [19/1/2003 1:30:42]

Generating Permutations generating partitions (see page ). Next: Generating Subsets Up: Combinatorial Problems Previous: Median and Selection Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK4/NODE151.HTM (5 of 5) [19/1/2003 1:30:42]

Generating Permutations<br />

Such subtleties demonstrate why you must be very careful with random generation algorithms. Indeed,<br />

we recommend that you try some reasonably extensive experiments with any random generator before<br />

really believing it. For example, generate 10,000 random permutations of length 4 and see whether all 24<br />

of them occur approximately the same number of times. If you understand how to measure statistical<br />

significance, you are in even better shape.<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 permutations and to<br />

sequence permutations in minimum-change order. Also included are routines to extract the cycle<br />

structure of a permutation. See Section for details.<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. Specifically, there is an interactive interface that lets you specify which<br />

type of objects you would like to construct and quickly returns the objects to you. It is well worth<br />

checking this out at http://sue.csc.uvic.ca/ cos/.<br />

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

permutations and sequence permutations in minimum change and lexicographic orders. It also<br />

provides a backracking routine to construct all distinct permutations of a multiset, and it supports various<br />

permutation group operations. See Section .<br />

<strong>The</strong> Stanford GraphBase (see Section ) contains routines to generate all permutations of a multiset.<br />

Notes: <strong>The</strong> primary reference on permutation generation is the survey paper by Sedgewick [Sed77].<br />

Good expositions include [NW78, RND77, Rus97].<br />

<strong>The</strong> fast permutation generation methods make only a single swap between successive permutations. <strong>The</strong><br />

Johnson-Trotter algorithm [Joh63, Tro62] satisfies an even stronger condition, namely that the two<br />

elements being swapped are always adjacent.<br />

In the days before ready access to computers, books with tables of random permutations [MO63] were<br />

used instead of algorithms. <strong>The</strong> swap-based random permutation algorithm presented above was first<br />

described in [MO63].<br />

Related Problems: Random number generation (see page ), generating subsets (see page ),<br />

file:///E|/BOOK/BOOK4/NODE151.HTM (4 of 5) [19/1/2003 1:30:42]

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

Saved successfully!

Ooh no, something went wrong!