The.Algorithm.Design.Manual.Springer-Verlag.1998
The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998
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]
- Page 387 and 388: Determinants and Permanents Next: C
- Page 389 and 390: Determinants and Permanents exposit
- Page 391 and 392: Constrained and Unconstrained Optim
- Page 393 and 394: Constrained and Unconstrained Optim
- Page 395 and 396: Linear Programming variable assignm
- Page 397 and 398: Linear Programming The book [MW93]
- Page 399 and 400: Random Number Generation Next: Fact
- Page 401 and 402: Random Number Generation is largely
- Page 403 and 404: Random Number Generation Related Pr
- Page 405 and 406: Factoring and Primality Testing The
- Page 407 and 408: Factoring and Primality Testing Alg
- Page 409 and 410: Arbitrary-Precision Arithmetic If y
- Page 411 and 412: Arbitrary-Precision Arithmetic PARI
- Page 413 and 414: Knapsack Problem Next: Discrete Fou
- Page 415 and 416: Knapsack Problem is a subset of S'
- Page 417 and 418: Discrete Fourier Transform Next: Co
- Page 419 and 420: Discrete Fourier Transform an algor
- Page 421 and 422: Combinatorial Problems Next: Sortin
- Page 423 and 424: Sorting Next: Searching Up: Combina
- Page 425 and 426: Sorting The simplest approach to ex
- Page 427 and 428: Sorting operations, implying an sor
- Page 429 and 430: Searching large performance improve
- Page 431 and 432: Searching Notes: Mehlhorn and Tsaka
- Page 433 and 434: Median and Selection followed by fi
- Page 435 and 436: Generating Permutations Next: Gener
- Page 437: Generating Permutations The rank/un
- Page 441 and 442: Generating Subsets look right when
- Page 443 and 444: Generating Subsets above for detail
- Page 445 and 446: Generating Partitions Although the
- Page 447 and 448: Generating Partitions Two related c
- Page 449 and 450: Generating Graphs generate: ● Do
- Page 451 and 452: Generating Graphs Combinatorica [Sk
- Page 453 and 454: Calendrical Calculations Next: Job
- Page 455 and 456: Calendrical Calculations Gregorian,
- Page 457 and 458: Job Scheduling ● To assign a set
- Page 459 and 460: Job Scheduling shop scheduling incl
- Page 461 and 462: Satisfiability logic, and automatic
- Page 463 and 464: Satisfiability Next: Graph Problems
- Page 465 and 466: Graph Problems: Polynomial-Time rec
- Page 467 and 468: Connected Components Testing the co
- Page 469 and 470: Connected Components discussing gra
- Page 471 and 472: Topological Sorting contradiction t
- Page 473 and 474: Minimum Spanning Tree Next: Shortes
- Page 475 and 476: Minimum Spanning Tree help you sort
- Page 477 and 478: Shortest Path Next: Transitive Clos
- Page 479 and 480: Shortest Path easier to program tha
- Page 481 and 482: Shortest Path Related Problems: Net
- Page 483 and 484: Transitive Closure and Reduction
- Page 485 and 486: Transitive Closure and Reduction Al
- Page 487 and 488: Matching augmenting paths and stopp
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]