# The Art of Computer Programming

The Art of Computer Programming (TAOCP) is a comprehensive multi-volume monograph written by the computer scientist Donald Knuth presenting programming algorithms and their analysis. At present it consists of published volumes 1,2,3,4A, and 4B, with more expected to be released in the future. The book is intended to represent the central core of computer programming for sequential machines.
When Knuth began the project in 1962, he originally conceived of it as a single book with twelve chapters. The first three volumes of what was then expected to be a seven-volume set were published in 1968, 1969, and 1973. Work began in earnest on Volume 4 in 1973, but was suspended in 1977 for work on typesetting prompted by the second edition of Volume 2. Writing of the final copy of Volume 4A began in longhand in 2001, and the first online pre-fascicle, 2A, appeared later in 2001. The first published installment of Volume 4 appeared in paperback as Fascicle 2 in 2005. The hardback Volume 4A, combining Volume 4, Fascicles 0–4, was published in 2011. Volume 4, Fascicle 6 ("Satisfiability") was released in December 2015; Volume 4, Fascicle 5 ("Mathematical Preliminaries Redux; Backtracking; Dancing Links") was released in November 2019.
Volume 4B consists of material evolved from Fascicles 5 and 6. The manuscript was sent to the publisher on August 1, 2022, and the volume was published in September 2022. Fascicle 7 (Constraint Satisfaction), planned for Volume 4C, was the subject of Knuth's talk on August 3, 2022 and was published on February 5, 2025.

## History

After winning a Westinghouse Talent Search scholarship, Knuth enrolled at the Case Institute of Technology (now Case Western Reserve University), where his performance was so outstanding that the faculty voted to award him a master of science upon his completion of the bachelor's degree. During his summer vacations, Knuth was hired by the Burroughs Corporation to write compilers, earning more in his summer months than full professors did for an entire year. Such exploits made Knuth a topic of discussion among the mathematics department, which included Richard S. Varga.
In January 1962, when he was a graduate student in the mathematics department at Caltech, Knuth was approached by Addison-Wesley to write a book about compiler design, and he proposed a larger scope. He came up with a list of twelve chapter titles the same day. In the summer of 1962 he worked on a FORTRAN compiler for UNIVAC, considering that he had "sold my soul to the devil" to develop a FORTRAN compiler$^{:15}$ after ALGOL developments with Burroughs. He remained as a consultant to Burroughs over the period 1960 to 1968 while writing Volume 1 "Fundamental Algorithms".
During this time, he also developed a mathematical analysis of linear probing, which convinced him to present the material with a quantitative approach. After receiving his Ph.D. in June 1963, he began working on his manuscript, of which he finished his first draft in June 1965, at 3000 hand-written pages. He had assumed that about five hand-written pages would translate into one printed page, but his publisher said instead that about 1+1⁄2 hand-written pages translated to one printed page. This meant he had approximately 2000 printed pages of material, which closely matches the size of the first three published volumes.
The first volume of "The Art of Computer Programming", "Fundamental Algorithms", took five years to complete between 1963 and 1968 while working at both Caltech and Burroughs.
Knuth's dedication in Volume 1 reads:
   This series of books is affectionately dedicated to the Type 650 computer once installed at Case Institute of Technology, in remembrance of many pleasant evenings.
In the preface, he thanks first his wife Jill, then Burroughs for the use of B220 and B5500 computers in testing most of the programs, and Caltech, the National Science Foundation, and the Office of Naval Research.$^{:xii}$
Section 2.5 of "Fundamental Algorithms" is on Dynamic Storage Allocation. Parts of this are used in the Burroughs approach to memory management. Knuth claims credit for “The “boundary-tag” method, introduced in Section 2.5, was designed by the author in 1962 for use in a control program for the B5000 computer.”$^{:460}$
Knuth received support from Richard S. Varga, who was the scientific adviser to the publisher. Varga was visiting Olga Taussky-Todd and John Todd at Caltech. With Varga's enthusiastic endorsement, the publisher accepted Knuth's expanded plans. In its expanded version, the book would be published in seven volumes, each with just one or two chapters. Due to the growth in Chapter 7, which was fewer than 100 pages of the 1965 manuscript, per Vol. 4A p. vi, the plan for Volume 4 has since expanded to include Volumes 4A, 4B, 4C, 4D, and possibly more.
In 1976, Knuth prepared a second edition of Volume 2, requiring it to be typeset again, but the style of type used in the first edition (called hot type) was no longer available. In 1977, he decided to spend some time creating something more suitable. Eight years later, he returned with T$_E$X, which is currently used for all volumes.
Another characteristic of the volumes is the variation in the difficulty of the exercises including a numerical rating varying from 0 to 50, where 0 is trivial, and 50 is an open question in contemporary research.

## Bounty for finding errors

The offer of a so-called Knuth reward check worth "one hexadecimal dollar" (100$_{HEX}$ base 16 cents, in decimal, is $2.56) for any errors found, and the correction of these errors in subsequent printings, has contributed to the highly polished and still-authoritative nature of the work, long after its first publication.

## Assembly language in the book

All examples in the books use a hypothetical language called "MIX assembly language" (MIXAL), which runs on "a mythical computer called MIX". Currently, the MIX computer is being replaced by the MMIX computer, which is a RISC version. The conversion from MIX to MMIX was a large ongoing project for which Knuth solicited volunteers for help. Software such as GNU MDK exists to provide emulation of the MIX architecture. Knuth considers the use of assembly language necessary for the speed and memory usage of algorithms to be judged.
MIX was much like any computer then in existence, but nicer. The name ‘MIX’ is 1009 in Roman numerals and this is given by a formula involving series numbers of several computers of the time: (360 + 650 + 709 + U3 + SS80 + 1107 + 1604 + G2- + B220 + S2000 + 920 + 601 + H800 + PDP-4 + 11)/16 = 1009 or MIX. The name MMIX is 2009 in Roman numerals and Knuth claims MMIX is even nicer than MIX.

## Critical response

Knuth was awarded the 1974 Turing Award "for his major contributions to the analysis of algorithms […], and in particular for his contributions to the 'art of computer programming' through his well-known books in a continuous series by this title." American Scientist has included this work among "100 or so Books that shaped a Century of Science", referring to the twentieth century. Covers of the third edition of Volume 1 quote Bill Gates as saying, "If you think you're a really good programmer… read (Knuth's) Art of Computer Programming… You should definitely send me a résumé if you can read the whole thing." The New York Times referred to it as "the profession's defining treatise".

## Volumes
### Completed

* Volume 1 – Fundamental algorithms
** Chapter 1 – Basic concepts
** Chapter 2 – Information structures
* Volume 2 – Seminumerical algorithms
** Chapter 3 – Random numbers
** Chapter 4 – Arithmetic
* Volume 3 – Sorting and searching
** Chapter 5 – Sorting
** Chapter 6 – Searching
* Volume 4A – Combinatorial algorithms
** Chapter 7 – Combinatorial searching (part 1)
* Volume 4B – Combinatorial algorithms
** Chapter 7 – Combinatorial searching (part 2)

### Planned

* Volume 4C, 4D, ... Combinatorial algorithms (chapters 7 & 8 released in several subvolumes)
** Chapter 7 – Combinatorial searching (continued)
** Chapter 8 – Recursion
* Volume 5 – Syntactic algorithms
** Chapter 9 – Lexical scanning (also includes string search and data compression)
** Chapter 10 – Parsing techniques
* Volume 6 – The Theory of context-free languages
** Chapter 11 – Mathematical linguistics
* Volume 7 – Compiler techniques
** Chapter 12 – Programming language translation

## Chapter outlines
### Completed
#### Volume 1 – Fundamental algorithms

* Chapter 1 – Basic concepts
** 1.1. Algorithms
** 1.2. Mathematical preliminaries
*** 1.2.1. Mathematical induction
*** 1.2.2. Numbers, powers, and logarithms
*** 1.2.3. Sums and products
*** 1.2.4. Integer functions and elementary number theory
*** 1.2.5. Permutations and factorials
*** 1.2.6. Binomial coefficients
*** 1.2.7. Harmonic numbers
*** 1.2.8. Fibonacci numbers
*** 1.2.9. Generating functions
*** 1.2.10. Analysis of an algorithm
*** 1.2.11. Asymptotic representations
**** 1.2.11.1. The O-notation
**** 1.2.11.2. Euler's summation formula
**** 1.2.11.3. Some asymptotic calculations
** 1.3 MMIX (MIX in the hardback copy but updated by fascicle 1)
*** 1.3.1. Description of MMIX
*** 1.3.2. The MMIX assembly language
*** 1.3.3. Applications to permutations
** 1.4. Some fundamental programming techniques
*** 1.4.1. Subroutines
*** 1.4.2. Coroutines
*** 1.4.3. Interpretive routines
**** 1.4.3.1. A MIX simulator
**** 1.4.3.2. Trace routines
*** 1.4.4. Input and output
*** 1.4.5. History and bibliography
* Chapter 2 – Information structures
** 2.1. Introduction
** 2.2. Linear lists
*** 2.2.1. Stacks, queues, and deques
*** 2.2.2. Sequential allocation
*** 2.2.3. Linked allocation (topological sorting)
*** 2.2.4. Circular lists
*** 2.2.5. Doubly linked lists
*** 2.2.6. Arrays and orthogonal lists
** 2.3. Trees
*** 2.3.1. Traversing binary trees
*** 2.3.2. Binary tree representation of trees
*** 2.3.3. Other representations of trees
*** 2.3.4. Basic mathematical properties of trees
**** 2.3.4.1. Free trees
**** 2.3.4.2. Oriented trees
**** 2.3.4.3. The "infinity lemma"
**** 2.3.4.4. Enumeration of trees
**** 2.3.4.5. Path length
**** 2.3.4.6. History and bibliography
*** 2.3.5. Lists and garbage collection
** 2.4. Multilinked structures
** 2.5. Dynamic storage allocation
** 2.6. History and bibliography

#### Volume 2 – Seminumerical algorithms

* Chapter 3 – Random numbers
** 3.1. Introduction
** 3.2. Generating uniform random numbers
*** 3.2.1. The linear congruential method
**** 3.2.1.1. Choice of modulus
**** 3.2.1.2. Choice of multiplier
**** 3.2.1.3. Potency
*** 3.2.2. Other methods
** 3.3. Statistical tests
*** 3.3.1. General test procedures for studying random data
*** 3.3.2. Empirical tests
*** 3.3.3. Theoretical tests
*** 3.3.4. The spectral test
** 3.4. Other types of random quantities
*** 3.4.1. Numerical distributions
*** 3.4.2. Random sampling and shuffling
** 3.5. What Is a random sequence?
** 3.6. Summary
* Chapter 4 – Arithmetic
** 4.1. Positional number systems
** 4.2. Floating point arithmetic
*** 4.2.1. Single-precision calculations
*** 4.2.2. Accuracy of floating point arithmetic
*** 4.2.3. Double-precision calculations
*** 4.2.4. Distribution of floating point numbers
** 4.3. Multiple precision arithmetic
*** 4.3.1. The classical algorithms
*** 4.3.2. Modular arithmetic
*** 4.3.3. How fast can we multiply?
** 4.4. Radix conversion
** 4.5. Rational arithmetic
*** 4.5.1. Fractions
*** 4.5.2. The greatest common divisor
*** 4.5.3. Analysis of Euclid's algorithm
*** 4.5.4. Factoring into primes
** 4.6. Polynomial arithmetic
*** 4.6.1. Division of polynomials
*** 4.6.2. Factorization of polynomials
*** 4.6.3. Evaluation of powers (addition-chain exponentiation)
*** 4.6.4. Evaluation of polynomials
** 4.7. Manipulation of power series

#### Volume 3 – Sorting and searching

* Chapter 5 – Sorting
** 5.1. Combinatorial properties of permutations
*** 5.1.1. Inversions
*** 5.1.2. Permutations of a multiset
*** 5.1.3. Runs
*** 5.1.4. Tableaux and involutions
** 5.2. Internal sorting
*** 5.2.1. Sorting by insertion
*** 5.2.2. Sorting by exchanging
*** 5.2.3. Sorting by selection
*** 5.2.4. Sorting by merging
*** 5.2.5. Sorting by distribution
** 5.3. Optimum sorting
*** 5.3.1. Minimum-comparison sorting
*** 5.3.2. Minimum-comparison merging
*** 5.3.3. Minimum-comparison selection
*** 5.3.4. Networks for sorting
** 5.4. External sorting
*** 5.4.1. Multiway merging and replacement selection
*** 5.4.2. The polyphase merge
*** 5.4.3. The cascade merge
*** 5.4.4. Reading tape backwards
*** 5.4.5. The oscillating sort
*** 5.4.6. Practical considerations for tape merging
*** 5.4.7. External radix sorting
*** 5.4.8. Two-tape sorting
*** 5.4.9. Disks and drums
** 5.5. Summary, history, and bibliography
* Chapter 6 – Searching
** 6.1. Sequential searching
** 6.2. Searching by comparison of keys
*** 6.2.1. Searching an ordered table
*** 6.2.2. Binary tree searching
*** 6.2.3. Balanced trees
*** 6.2.4. Multiway trees
** 6.3. Digital searching
** 6.4. Hashing
** 6.5. Retrieval on secondary keys

#### Volume 4A – Combinatorial algorithms, Part 1

* Chapter 7 – Combinatorial searching
** 7.1. Zeros and ones
*** 7.1.1. Boolean basics
*** 7.1.2. Boolean evaluation
*** 7.1.3. Bitwise tricks and techniques
*** 7.1.4. Binary decision diagrams
** 7.2. Generating all possibilities
*** 7.2.1. Generating basic combinatorial patterns
**** 7.2.1.1. Generating all n-tuples
**** 7.2.1.2. Generating all permutations
**** 7.2.1.3. Generating all combinations
**** 7.2.1.4. Generating all integer partitions
**** 7.2.1.5. Generating all set partitions
**** 7.2.1.6. Generating all trees
**** 7.2.1.7. History and further references

#### Volume 4B – Combinatorial algorithms, Part 2

* Chapter 7 – Combinatorial searching (continued)
** 7.2. Generating all possibilities (continued)
*** 7.2.2. Backtrack programming
**** 7.2.2.1. Dancing links (includes discussion of exact cover)
**** 7.2.2.2. Satisfiability

### Planned
#### Volumes 4C, 4D, 4E, 4F – Combinatorial algorithms

* Chapter 7 – Combinatorial searching (continued)
** 7.2. Generating all possibilities (continued)
*** 7.2.2. Backtrack programming (continued)
**** 7.2.2.3. Constraint satisfaction (released as Pre-Fascicle 7A)
**** 7.2.2.4. Hamiltonian paths and cycles
**** 7.2.2.5. Cliques
**** 7.2.2.6. Covers (vertex cover, set cover problem, exact cover, clique cover)
**** 7.2.2.7. Squares
**** 7.2.2.8. A potpourri of puzzles (includes perfect digital invariant)
**** 7.2.2.9. Estimating backtrack costs (chapter 6 of "Selected Papers on Analysis of Algorithms", and Fascicle 5, pp. 44−47, under the heading "Running time estimates")
*** 7.2.3. Generating inequivalent patterns (includes discussion of Pólya enumeration theorem) (see "Techniques for Isomorph Rejection", chapter 4 of "Classification Algorithms for Codes and Designs" by Kaski and Östergård)
** 7.3. Shortest paths
** 7.4. Graph algorithms
*** 7.4.1. Components and traversal
**** 7.4.1.1. Union-find algorithms
**** 7.4.1.2. Depth-first search
**** 7.4.1.3. Vertex and edge connectivity
*** 7.4.2. Special classes of graphs
*** 7.4.3. Expander graphs
*** 7.4.4. Random graphs
** 7.5. Graphs and optimization
*** 7.5.1. Bipartite matching (including maximum-cardinality matching, stable marriage problem, mariages stables)
*** 7.5.2. The assignment problem
*** 7.5.3. Network flows
*** 7.5.4. Optimum subtrees
*** 7.5.5. Optimum matching
*** 7.5.6. Optimum orderings
** 7.6. Independence theory
*** 7.6.1. Independence structures
*** 7.6.2. Efficient matroid algorithms
** 7.7. Discrete dynamic programming (see also transfer-matrix method)
** 7.8. Branch-and-bound techniques
** 7.9. Herculean tasks (aka NP-hard problems)
** 7.10. Near-optimization
* Chapter 8 – Recursion (chapter 22 of "Selected Papers on Analysis of Algorithms")

#### Volume 5 – Syntactic algorithms

* Chapter 9 – Lexical scanning (includes also string search and data compression)
* Chapter 10 – Parsing techniques

#### Volume 6 – The theory of context-free languages

* Chapter 11 – Mathematical linguistics

#### Volume 7 – Compiler techniques

* Chapter 12 – Programming language translation

## English editions
### Current editions

These are the current editions in order by volume number:
* The Art of Computer Programming, Volumes 1-4B Boxed Set. (Reading, Massachusetts: Addison-Wesley, 2023), 3904pp. ISBN 978-0-13-793510-9, 0-13-793510-2
** Volume 1: Fundamental Algorithms. Third Edition (Reading, Massachusetts: Addison-Wesley, 1997), xx+650pp. ISBN 978-0-201-89683-1, 0-201-89683-4. Errata: (from 2011-01-08), (from 2022, 49th printing). Addenda: (2011).
** Volume 2: Seminumerical Algorithms. Third Edition (Reading, Massachusetts: Addison-Wesley, 1997), xiv+762pp. ISBN 978-0-201-89684-8, 0-201-89684-2. Errata: (from 2011-01-08), (from 2022, 45th printing). Addenda: (2011).
** Volume 3: Sorting and Searching. Second Edition (Reading, Massachusetts: Addison-Wesley, 1998), xiv+780pp.+foldout. ISBN 978-0-201-89685-5, 0-201-89685-0. Errata: (from 2011-01-08), (from 2022, 45th printing). Addenda: (2011).
** Volume 4A: Combinatorial Algorithms, Part 1. First Edition (Upper Saddle River, New Jersey: Addison-Wesley, 2011, 24th printing), xv+883pp. ISBN 978-0-201-03804-0, 0-201-03804-8. Errata: (from 2011), (from 2022, 20th printing).
** Volume 4B: Combinatorial Algorithms, Part 2. First Edition (Upper Saddle River, New Jersey: Addison-Wesley, 2023), xviii+714pp. ISBN 978-0-201-03806-4, 0-201-03806-4. Errata: (from 2023, 1st printing).
* Volume 1, Fascicle 1: MMIX – A RISC Computer for the New Millennium. (Addison-Wesley, 2005-02-14), 144pp. ISBN 0-201-85392-2. Errata: (from 2005, 1st printing) (will be in the fourth edition of volume 1)
* The MMIX Supplement by Martin Ruckert. (Addison-Wesley), 193pp. ISBN 0-13-399231-4. A conversion of the MIX problems/programs in volumes 1, 2 & 3 to MMIX.
* Volume 4, Fascicle 7: Constraint Satisfaction. (Addison-Wesley, 2025-02-05), xiv+281pp. ISBN 978-0-13-532824-8.

### Previous editions
#### Complete volumes

These volumes were superseded by newer editions and are in order by date.
* Volume 1: Fundamental Algorithms. First edition, 1968, xxi+634pp, ISBN 0-201-03801-3.
* Volume 2: Seminumerical Algorithms. First edition, 1969, xi+624pp, ISBN 0-201-03802-1.
* Volume 3: Sorting and Searching. First edition, 1973, xi+723pp+foldout, ISBN 0-201-03803-X. Errata: .
* Volume 1: Fundamental Algorithms. Second edition, 1973, xxi+634pp, ISBN 0-201-03809-9. Errata: .
* Volume 2: Seminumerical Algorithms. Second edition, 1981, xiii+ 688pp, ISBN 0-201-03822-6. Errata: .
* The Art of Computer Programming, Volumes 1-3 Boxed Set. Second Edition (Reading, Massachusetts: Addison-Wesley, 1998), pp. ISBN 978-0-201-48541-7, 0-201-48541-9
* The Art of Computer Programming, Volumes 1-4A Boxed Set. Third Edition (Reading, Massachusetts: Addison-Wesley, 2011), 3168pp. ISBN 978-0-321-75104-1, 0-321-75104-3

#### Fascicles

Volume 4, Fascicles 0–4 were revised and published as Volume 4A.
* Volume 4, Fascicle 0: Introduction to Combinatorial Algorithms and Boolean Functions. (Addison-Wesley Professional, 2008-04-28) vi+240pp, ISBN 0-321-53496-4. Errata: (2011-01-01).
* Volume 4, Fascicle 1: Bitwise Tricks & Techniques; Binary Decision Diagrams. (Addison-Wesley Professional, 2009-03-27) viii+260pp, ISBN 0-321-58050-8. Errata: (2011-01-01).
* Volume 4, Fascicle 2: Generating All Tuples and Permutations. (Addison-Wesley, 2005-02-14) v+127pp, ISBN 0-201-85393-0. Errata: (2011-01-01).
* Volume 4, Fascicle 3: Generating All Combinations and Partitions. (Addison-Wesley, 2005-07-26) vi+150pp, ISBN 0-201-85394-9. Errata: (2011-01-01).
* Volume 4, Fascicle 4: Generating All Trees; History of Combinatorial Generation. (Addison-Wesley, 2006-02-06) vi+120pp, ISBN 0-321-33570-8. Errata: (2011-01-01).
Volume 4, Fascicles 5–6 were revised and published as Volume 4B.
* Volume 4, Fascicle 5: Mathematical Preliminaries Redux; Backtracking; Dancing Links. (Addison-Wesley, 2019-11-22) xiii+382pp, ISBN 978-0-13-467179-6. Errata: (2020-03-27)
* Volume 4, Fascicle 6: Satisfiability. (Addison-Wesley, 2015-12-08) xiii+310pp, ISBN 978-0-13-439760-3. Errata: (2020-03-26)

#### Pre-fascicles

Volume 1
* Pre-fascicle 1 was revised and published as Volume 1, fascicle 1.
Volume 4
* Pre-fascicles 0A, 0B, and 0C were revised and published as Volume 4, fascicle 0.
* Pre-fascicles 1A and 1B were revised and published as Volume 4, fascicle 1.
* Pre-fascicles 2A and 2B were revised and published as Volume 4, fascicle 2.
* Pre-fascicles 3A and 3B were revised and published as Volume 4, fascicle 3.
* Pre-fascicles 4A and 4B were revised and published as Volume 4, fascicle 4.
* Pre-fascicles 5A, 5B, and 5C were revised and published as Volume 4, fascicle 5.
* Pre-fascicle 6A was revised and published as Volume 4, fascicle 6.
* Pre-fascicle 7A was revised and published as Volume 4, fascicle 7.
The remaining pre-fascicles contain draft material that is set to appear in future fascicles and volumes.
* Volume 4, Pre-fascicle 8A: Hamiltonian Paths and Cycles
* Volume 4, Pre-fascicle 8B: Cliques
* Volume 4, Pre-fascicle 9B: A Potpourri of Puzzles
* Volume 4, Pre-fascicle 9C: Estimating Backtrack Costs
* Volume 4, Pre-fascicle 12A: Components and Traversal (PDF Version)
* Volume 4, Pre-fascicle 14A: Bipartite Matching
* Volume 4, Pre-fascicle 16A: Introduction to Recursion