The Art of Computer Programming, Volume 3: Sorting and Searching (2nd Edition)

The Art of Computer Programming, Volume 3: Sorting and Searching (2nd Edition)

Donald E. Knuth

Language: English

Pages: 1

ISBN: 0201896850

Format: PDF / Kindle (mobi) / ePub


The first revision of this third volume is the most comprehensive survey of classical computer techniques for sorting and searching. It extends the treatment of data structures in Volume 1 to consider both large and small databases and internal and external memories. The book contains a selection of carefully checked computer methods, with a quantitative analysis of their efficiency. Outstanding features of the second edition include a revised section on optimum sorting and new discussions of the theory of permutations and of universal hashing.

http://img113.imageshack.us/img113/1433/knuth3.png

 

 

 

 

 

 

 

 

 

 

 

current floor) equal to 1: K1. [Move up.] From among the b + m people currently in the elevator or on floor k, those m with the highest destinations get into the elevator, and the others remain on floor k. Let there be u people now in the elevator whose destination is > k, and d whose destination is 蠄 k. (It will turn out that u = min(m, uk); if uk < m we may therefore be transporting some people away from their destination. This represents their sacrifice to the common good.) Decrease uk by u,

舠logarithmic search舡 or 舠bisection,舡 but it is most commonly called binary search. Fig. 3. Binary search. Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky, and many good programmers have done it wrong the first few times they tried. One of the most popular correct forms of the algorithm makes use of two pointers, l and u, that indicate the current lower and upper limits for the search, as follows: Algorithm B (Binary search).

s readings, if rs < n; but such permutations do exist if n 蠅 n + 1 蜢 r 蠅 s 蠅 1 and rs 蠅 n. 23. [HM42] (Walter Weissblum.) The 舠long runs舡 of a permutation a1 a2 . . . an are obtained by placing vertical lines just before a segment fails to be monotonic; long runs are either increasing or decreasing, depending on the order of their first two elements, so the length of each long run (except possibly the last) is 蠅 2. For example, 7 5 | 6 2 | 3 8 9 | 1 4 has four long runs. Find the average length

fields; this is the so-called multilist method illustrated in Fig. 13 of Section 2.2.6 and discussed further below. A third possibility is to combine the three files into one super file, by analogy with library card catalogues in which author cards, title cards, and subject cards are all alphabetized together. A consideration of the format used in the index to this book leads to further ideas on inverted list representation. For secondary key fields in which there are typically five or so

f(f(m)) elements. This proves the stated result, since f(f(m)) > m2 when m > 24. (The construction is not 舠tight,舡 so we can probably do the job with substantially fewer than 16 levels.) 55. [If P (n) denotes the minimum number of switches needed in a permutation network, it is clear that P (n) 蠅 lg n!. By slightly extending a construction due to L. J. Goldstein and S. W. Leibholz, IEEE Trans. EC-16 (1967), 637舑641, one can show that P (n) 蠄 P (n/2) + P (n/2) + n 蜢 1, hence P (n) 蠄 B(n) for all

Download sample

Download