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

Median and Selection an animation of the linear-time selection algorithm. This animation is a good one. Notes: The linear expected-time algorithm for median and selection is due to Hoare [Hoa61]. Floyd and Rivest [FR75] provide an algorithm that uses fewer comparisons on average. Good expositions on lineartime selection include [AHU74, Baa88, CLR90, Raw92], with [Raw92] being particularly enlightening. A sport of considerable theoretical interest is determining exactly how many comparisons are sufficient to find the median of n items. The linear-time algorithm of Blum et. al. [BFP 72] proves that suffice, but we want to know what c is. A lower bower bound of 2n comparisons for median finding was given by Bent and John [BJ85]. In 1976, Schönhage, Paterson, and Pippenger [SPP76] presented an algorithm using 3n comparisons. Recently, Dor and Zwick [DZ95] proved that 2.95 n comparisons suffice. These algorithms attempt to minimize the number of element comparisons but not the total number of operations, and hence do not lead to faster algorithms in practice. Tight combinatorial bounds for selection problems are presented in [Aig88]. An optimal algorithm for computing the mode is presented in [DM80]. Related Problems: Priority queues (see page ), sorting (see page ). Next: Generating Permutations Up: Combinatorial Problems Previous: Searching Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK4/NODE150.HTM (3 of 3) [19/1/2003 1:30:40]

Generating Permutations Next: Generating Subsets Up: Combinatorial Problems Previous: Median and Selection Generating Permutations Input description: An integer n. Problem description: Generate (1) all or (2) a random or (3) the next permutation of length n. Discussion: A permutation describes an arrangement, or ordering, of things. Many algorithmic problems in this catalog seek the best way to order a set of objects, including traveling salesman (the least-cost order to visit n cities), bandwidth (order the vertices of a graph on a line so as to minimize the length of the longest edge), and graph isomorphism (order the vertices of one graph so that it is identical to another). Any algorithm for solving such problems exactly must construct a series of permutations along the way. There are n! permutations of n items, which grows so quickly that you can't expect to generate all permutations for n > 11, since 11! = 39,916,800. Numbers like these should cool the ardor of anyone interested in exhaustive search and help explain the importance of generating random permutations. Fundamental to any permutation-generation algorithm is a notion of order, the sequence in which the permutations are constructed, from first to last. The most natural generation order is lexicographic, the order they would appear if they were sorted numerically. Lexicographic order for n=3 is , file:///E|/BOOK/BOOK4/NODE151.HTM (1 of 5) [19/1/2003 1:30:42]

Generating Permutations<br />

Next: Generating Subsets Up: Combinatorial Problems Previous: Median and Selection<br />

Generating Permutations<br />

Input description: An integer n.<br />

Problem description: Generate (1) all or (2) a random or (3) the next permutation of length n.<br />

Discussion: A permutation describes an arrangement, or ordering, of things. Many algorithmic problems<br />

in this catalog seek the best way to order a set of objects, including traveling salesman (the least-cost<br />

order to visit n cities), bandwidth (order the vertices of a graph on a line so as to minimize the length<br />

of the longest edge), and graph isomorphism (order the vertices of one graph so that it is identical to<br />

another). Any algorithm for solving such problems exactly must construct a series of permutations along<br />

the way.<br />

<strong>The</strong>re are n! permutations of n items, which grows so quickly that you can't expect to generate all<br />

permutations for n > 11, since 11! = 39,916,800. Numbers like these should cool the ardor of anyone<br />

interested in exhaustive search and help explain the importance of generating random permutations.<br />

Fundamental to any permutation-generation algorithm is a notion of order, the sequence in which the<br />

permutations are constructed, from first to last. <strong>The</strong> most natural generation order is lexicographic, the<br />

order they would appear if they were sorted numerically. Lexicographic order for n=3 is ,<br />

file:///E|/BOOK/BOOK4/NODE151.HTM (1 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!