The first volume in the series begins with basic
programming concepts and techniques, then focuses more
particularly on information structures-the representation
of information inside a computer, the structural
relationships between data elements and how to deal with
them efficiently. Elementary applications are given to
simulation, numerical methods, symbolic computing, software
and system design. Dozens of simple and important
algorithms and techniques have been added to those of the
previous edition. The section on mathematical preliminaries
has been extensively revised to match present trends in
research.
The second volume offers a complete introduction to the
field of seminumerical algorithms, with separate chapters
on random numbers and arithmetic. The book summarizes the
major paradigms and basic theory of such algorithms,
thereby providing a comprehensive interface between
computer programming and numerical analysis. Particularly
noteworthy in this third edition is Knuth's new treatment
of random number generators, and his discussion of
calculations with formal power series.
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.
Table of Contents Chapter 1-Basic Concepts ..... 1
1.1. Algorithms ..... 1
1.2. Mathematical Preliminaries ..... 10
1.2.1. Mathematical Induction ..... 11
1.2.2. Numbers, Powers, and Logarithms ..... 21
1.2.3. Sums and Products ..... 27
1.2.4.
Integer Functions and Elementary Number Theory
..... 39
1.2.5. Permutations and Factorials ..... 45
1.2.6. Binomial Coefficients ..... 52
1.2.7. Harmonic Numbers ..... 75
1.2.8. Fibonacci Numbers ..... 79
1.2.9. Generating Functions ..... 87
1.2.10. Analysis of an Algorithm 96
*1.2.11. Asymptotic Representations ..... 107
*1.2.11.1. The O-notation ..... 107
*1.2.11.2. Euler's summation formula .... 111
*1.2.11.3. Some asymptotic calculations ..... 116
1.3. MIX 124
1.3.1. Description of MIX ..... 124
1.3.2. The MIX Assembly Language ..... 144
1.3.3. Applications to Permutations ..... 164
1.4. Some Fundamental Programming Techniques .....
186
1.4.1. Subroutines ..... 186
1.4.2. Goroutines ..... 193
1.4.3. Interpretive Routines ..... 200
1.4.3.1. A MIX simulator ..... 202
*1.4.3.2. Trace routines ..... 212
1.4.4. Input and Output ..... 215
1.4.5. History and Bibliography ..... 229
Chapter 2--Information Structures ..... 232
2.1. Introduction ..... 232
2.2. Linear Lists ..... 238
2.2.1. Stacks, Queues, and Deques ..... 238
2.2.2. Sequential Allocation ..... 244
2.2.3. Linked Allocation ..... 254
2.2.4. Circular Lists ..... 273
2.2.5. Doubly Linked Lists ..... 280
2 2.6. Arrays and Orthogonal Lists ..... 298
2.3.
Trees ..... 308
2.3.1. Traversing Binary Trees ..... 318
2.3.2. Binary Tree Representation of Trees ..... 334
2.3.3. Other Representations of Trees ..... 348
2.3.4. Basic Mathematical Properties of Trees .....
362
2.3.4.1. Free trees ..... 363
2.3.4.2. Oriented trees ..... 372
*2.3.4.3. The "infinity lemma" ..... 382
*2.3.4.4. Enumeration of trees ..... 386
2.3.4.5. Path length ..... 399
*2.3.4.6. History and bibliography ..... 406
2.3.5. Lists and Garbage Collection ..... 408
2.4. Multilinked Structures ..... 424
2.5. Dynamic Storage Allocation ..... 425
History and Bibliography ..... 457
Answers to Exercises ..... 466
Appendix A--Tables of Numerical Quantities .....
619
1. Fundamental Constants (decimal) ..... 619
2. Fundamental Constants (octal) ..... 620
3. Harmonic Numbers, Bernoulli Numbers, Fibonacci Numbers
..... 621
Appendix B--Index to Notations ..... 623
Index and Glossary ..... 628
3. Random Numbers.
Introduction.
Generating Uniform Random Numbers.
The Linear Congruential Method.
Other Methods.
Statistical Tests.
General Test Procedures for Studying Random Data.
Empirical Tests.
Theoretical Tests.
The Spectral Test.
Other Types of Random Quantities.
Numerical Distributions.
Random Sampling and Shuffling.
What Is a Random Sequence?
Summary.
4. Arithmetic. Positional Number
Systems.
Floating Point Arithmetic.
Single-Precision Calculations.
Accuracy of Floating Point Arithmetic.
Double-Precision Calculations.
Distribution of Floating Point Numbers.
Multiple Precision Arithmetic.
The Classical Algorithms.
Modular Arithmetic.
How Fast Can We Multiply?.
Radix Conversion.
Rational Arithmetic.
Fractions.
The Greatest Common Divisor.
Analysis of Euclid's Algorithm.
Factoring into Primes.
Polynomial Arithmetic.
Division of Polynomials.
Factorization of Polynomials.
Evaluation of Powers.
Evaluation of Polynomials.
Manipulation of Power Series.
Answers to Exercises.
Appendix A: Tables of Numerical Quantities. Fundamental Constants
(decimal).
Fundamental Constants (octal).
Harmonic Numbers, Bernoulli Numbers, Fibonacci
Numbers.
Appendix B: Index to Notations. Index and Glossary. 5. Sorting. Combinatorial Properties
of Permutations.
Inversions.
Permutations of a Multiset.
Runs.
Tableaux and Involutions.
Internal sorting.
Sorting by
Insertion.
Sorting by Exchanging.
Sorting by Selection.
Sorting by Merging.
Sorting by Distribution.
Optimum Sorting.
Minimum-Comparison
Sorting.
Minimum-Comparison Merging.
Minimum-Comparison Selection.
Networks for Sorting.
External Sorting.
Multiway Merging and
Replacement Selection.
The Polyphase Merge.
The Cascade Merge.
Reading Tape Backwards.
The Oscillating Sort.
Practical Considerations for Tape Merging.
External Radix Sorting.
Two-Tape Sorting.
Disks and Drums.
Summary, History, and Bibliography.
6. Searching. Sequential
Searching.
Searching by Comparison of Keys.
Searching an Ordered
Table.
Binary Tree Searching.
Balanced Trees.
Multiway Trees.
Digital Searching.
Hashing.
Retrieval on Secondary Keys.
Answers to Exercises. Appendix A: Tables of Numerical Quantities. Fundamental Constants
(decimal).
Fundamental Constants (octal).
Harmonic Numbers, Bernoulli Numbers, Fibonacci
Numbers.
Appendix B:Index to Notations. Index and Glossary.