% CHANGES TO VOLUME 3 OF THE ART OF COMPUTER PROGRAMMING % % Copyright (C) 2011, 2012, 2013 by Donald E. Knuth % This file may be freely copied provided that no modifications are made. % All other rights are reserved. % % Three levels of changes to the books are distinguished here: % % "\bugonpage" introduces the correction of an error; % "\amendpage" introduces new material for future editions; % "\improvepage" introduces ameliorations of lesser importance. % % (Changes introduced by \improvepage do not appear in the hardcopy listing.) % % Also, "\planforpage" introduces some of the author's half-baked intentions. % % NOTE: TO PUT THE INDEX ON A SEPARATE PAGE, RUN THIS WITH THE COMMAND LINE % tex "\let\indexeject+ \input err3" \newif\ifall % \alltrue means show the trivial items too \relax % hook \def\vertical{|} \def\inref#1 #{\expandafter\def\csname\vertical#1\endcsname} \catcode`|=\active \let|\inref \input \jobname.ref \catcode`|=12 \input taocpmac % use the format for TAOCP, with modifications below \def\becomes{\ifmmode\ \hbox\fi{\manfnt y}\ } % wiggly arrow indicates a change \def\bugonpage#1.#2 #3 (#4) { \medbreak\defaultpointsize \line{\kern-5pt\llap{\manfnt x}% print a black triangle in left margin {\bf Page #2}\enspace #3 \leaders\hrule\hfill\ \eightrm\date#4.} \nobreak\smallskip\iftrue\noindent} \def\amendpage#1.#2 #3 (#4) { \medbreak\defaultpointsize \line{\kern-5pt{\bf Page #2}\enspace #3 \leaders\hrule\hfill\ \eightrm\date#4.} \nobreak\smallskip\iftrue\noindent} \def\improvepage#1.#2 #3 (#4) {\ifall \medbreak\ninepoint \line{\kern-6pt{\sl Page #2\enspace #3\/} \leaders\hrule\hfill\ \eightrm\date#4.} \nobreak\smallskip\noindent} \def\planforpage#1.#2 #3 (#4) { \medbreak\defaultpointsize \line{\kern-5pt{\bf Page #2}\enspace #3 \leaders\hbox to 5pt{\hss.\hss}\hfill\ \eightrm\date#4.} \nobreak\smallskip\begingroup\let\endchange=\endgroup\sl\noindent} \let\endchange=\fi \def\nl{\par\noindent} \def\nlh{\par\noindent\hangit} \def\hangit{\hangindent2em} \def\cutpar{{\parfillskip=0pt\par}} \def\date#1.#2.#3.{% convert "yy.mm.dd." to "dd Mon 19yy" #3 \ifcase#2\or Jan\or Feb\or Mar\or Apr\or May\or Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi \ \ifnum #1<97 \hundred#1\else19#1\fi} \def\hundred{20} % the "century" for dates before '97 \def\ex #1. [#2]{\ninepoint \textindent{\bf#1.}[{\it#2\/}]\kern6pt} \def\EX #1. [#2]{\ninepoint \textindent{\llap{\manfnt x}\bf#1.}[{\it#2\/}]\kern6pt} \def\foottext#1{\medskip \hrule height\ruleht width5pc \kern-\ruleht \kern3pt \eightpoint \smallskip\textindent{#1}} \def\volheadline#1{\line{\cleaders\hbox{\raise3pt\hbox{\manfnt\char'36}}\hfill \titlefont\ #1\ \cleaders\hbox{\raise3pt\hbox{\manfnt\char'36}}\hfill}} \def\refin#1 {\let|\inref \input #1.ref \let|\crossref} \let\defaultpointsize=\tenpoint %%%%%%%%%%%%%% opening remarks %%%%%%%%%%%%%%%%%%%%%%%% \def\lhead{INTRODUCTION} \let\rhead=\lhead \titlepage \volheadline{THE ART OF COMPUTER PROGRAMMING} \bigskip \volheadline{ERRATA TO VOLUME 3 (after 2010)} \bigskip \noindent This document is a transcript of the notes that I have been making in my personal copy of {\sl The Art of Computer Programming}, Volume~3 (second edition, 27th printing) since it was first printed in 2011. Previous errata are recorded in another file `{\tt all3-pre.ps}'. \ifall Four levels of updates\dash---``errors,'' ``amendments,'' ``plans,'' and ``improvements''\dash---appear, indicated by four \else Three levels of updates\dash---``errors,'' ``amendments,'' and ``plans''\dash---appear, indicated by three \fi different typographic conventions: \begingroup\def\hundred{17} \bugonpage 0.666 line 1 (76.07.04) Technical or typographical errors (aka bugs) are the most critical items, so they are flagged with a `\thinspace{\manfnt x}\thinspace' preceding the page number. The date on which I first was told about the bug is shown; this is the effective date on which I paid the finder's fee. The necessary corrections are indicated in a straightforward way. If,~for example, the book says `$n$' where it should have said `$n+1$', the change is shown thus: \smallskip $n$ \becomes $n+1$ \endchange \amendpage 0.666 line 2 (89.07.14) Amendments to the text appear in the same format as bugs, but without the~`\thinspace{\manfnt x}\thinspace'. These are things I wish I had known about or thought of when I wrote the original text, so I added them later. The date is the date I drafted the new text. \endchange \def\hundred{19} \planforpage 0.666 line 3 (17.11.20) Plans for the future represent a third kind of item. In such notes I~sketched my intentions about things that I wasn't ready to flesh out further when I~wrote them down. You can identify these items because they're written in slanted type, and preceded by a bunch of dots `\hbox to 6em{\leaders\hbox to 5pt{\hss.\hss}\hfill}' leading to the date on which I recorded the plan in my files. \endchange \improvepage 0.666 line 4 (38.01.10) The fourth and final category\dash---indicated by page and line number in smaller, slanted type\dash---consists of minor corrections or improvements that most readers don't want to know about, because they are so trivial. You wouldn't even be seeing these items if you hadn't specifically chosen to print the complete errata list in all its gory details. Are you sure you wanted to do that? \endchange \endgroup \ifall\else\medskip\ninepoint My personal file of updates also includes a fourth category of items, not shown in this list. They are miscellaneous minor corrections or improvements that most readers don't want to know about, because they are so trivial. If you really want to see all of the gory details, you can download the full list from Internet webpage $$\.{http://www-cs-faculty.stanford.edu/\char`\~knuth/taocp.html}$$ by selecting the ``long form'' of the errata. \fi \medskip \tenpoint My shelves at home are bursting with preprints and reprints of significant research results that I want to digest and summarize, where appropriate, in the ultimate edition of Volume~3. I didn't do that in the second edition because I would surely have to do it over again later: New results continue to pour forth at a great rate, and I will have time to rewrite that volume only~once. Volumes 4 and~5 need to be finished first. So I've put most of my effort so far into writing up those parts of the total picture that seem to have converged to their near-final form. It follows, somewhat paradoxically, that the updates in this document are most current in the areas where there has been least activity. On the other hand I do believe that the changes listed here bring Volume~3 completely up to date in two respects: (1)~All of the research problems in the previous edition\dash---i.e., all exercises that were rated 46 and above\dash---have received new ratings of 45 or less whenever I learned of a solution; and in such cases, the answer now refers to that solution. (2)~All of the historical information about pioneering developments has been amended whenever new details have come to my attention. \beginconstruction The ultimate, glorious, 100\% perfect editions of Volumes 1--4A are works in progress. Please let me know of any improvements that you think I ought to make. Send your comments either by snail mail to D.~E. Knuth, Computer Science, Gates Building 4B, Stanford University, Stanford CA~94305-9045, or by email to {\tt taocp{\char`\@}cs.stanford.edu}. (Use email for book suggestions only, please\dash---all other correspondence is returned unread to the sender, or discarded, because I have no time to read ordinary email.) Although I'm working full time on Volume~4B these days, I~will try to reply to all such messages within a year of receipt. Current news about {\sl The Art of Computer Programming\/} is posted on $$\.{http://www-cs-faculty.stanford.edu/\char`~knuth/taocp.html}$$ and updated regularly. \par\endconstruction \rightline{\dash---Don Knuth, February 1998} \bigskip \bigskip {\quoteformat Writing a series like {\rm The Art of Computer Programming} is similar to painting the Forth Rail Bridge. No sooner is it finished than the job must be started again. \author MALCOLM CLARK (1992) % A plain TeX primer, Oxford University Press, page 7 \bigskip\bigskip The time when\/ {\rm The Guardian} ceases to make mistakes altogether is not, at the moment, foreseeable. \author IAN MAYES (1998) % quoted in IHT, 17 Feb 98, p5 % he is Reader's Editor of the Manchester Guardian \vfill\eject } \def\today{\number\day\space\ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year} %%%%%%%%%%%%%%% CHANGES FOR VOLUME 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\lhead{CHANGES TO VOLUME 3: SORTING AND SEARCHING} \let\rhead=\lhead \titlepage \volheadline{SORTING AND SEARCHING} \bigskip \rightline{Copyright \copyright\ 2011, 2012, 2013 Addison\with Wesley; all rights reserved} \rightline{Last updated \today} \bigskip \rightline{\sl Most of these corrections have already been made in recent printings.} \smallskip \let\defaultpointsize=\tenpoint \amendpage 3.x line 16 (11.06.16) a {\it 45\/} rating \becomes a {\it 40\/} rating \endchange \amendpage 3.x line 20 (13.01.30) creativity.\ \becomes creativity. All exercises with ratings of {\it46\/} or more are open problems for future research, rated according to the number of different attacks that they've resisted so far. \endchange \bugonpage 3.xii line 8 (12.04.04) \ninepoint Internal sorting \becomes Internal Sorting \endchange \amendpage 3.34 in exercise 22 (12.04.13) \ninepoint line 6: $0^k$ \becomes $0^p$ (twice)\nl line 6: $k\ge0$ \becomes $p\ge0$\vadjust{\smallskip}\nl line $-3$: $\displaystyle \sum_{k\ge0}{k!^2(n_{\le t}-k)!\,(n_{>t}-k)!\over n_1!\ldots n_m!}$ \becomes $\displaystyle \sum_{p\ge0}{p!^2(n_{\le t}-p)!\,(n_{>t}-p)!\over n_1!\ldots n_m!}$\nl line $-1$: $p_{\le t}=p_{>t}=k$ \becomes $p_{\le t}=p_{>t}=p$ \endchange \bugonpage 3.111 in Fig.~17 on the arrow $\rm M3\to M4$ (12.06.07) \ninepoint $i\land p=r$ \becomes $i\band p=r$ \endchange \amendpage 3.129 line $-5$ (11.07.16) used before \becomes used at the end of Section 5.1.4 \endchange \amendpage 3.133 the line following {\eq(48)} (11.11.05) ignore $\delta(n)$ \becomes ignore the ``wobbles'' of $\delta(n)$ \endchange \bugonpage 3.174 line {\it20\/} of the {\tt MIX} program (12.02.04) \ninepoint To R3 if end of pass. \becomes To R3 if not end of pass. \endchange \bugonpage 3.202 line $-16$ (11.05.16) F. Hwang \becomes F. K. Hwang \endchange \bugonpage 3.205 line 1 of exercise 11 (11.05.16) \ninepoint F. Hwang \becomes F. K. Hwang \endchange \improvepage 3.210 in {\eq(6)} (13.01.20) $n\ge t$ \becomes $1\le t \le n$ \endchange \improvepage 3.253 new sentence at end of the caption for Fig.~62 (13.01.20) \ninepoint There are $P=12$ external nodes. \endchange \improvepage 3.261 line $-2$ and page 262 line 1 (13.01.20) $X$ \becomes $K$\qquad[6 times] \endchange \bugonpage 3.264 line 2 of exercise 17 (13.01.20) $K_1\ge K_2\ge \cdots \ge K_N$ \becomes $K_1>K_2>\cdots>K_N$ \endchange \bugonpage 3.315 bottom line [but only in 17th--28th printings!] (11.03.27) instead of as a \becomes instead of as \endchange \bugonpage 3.423 line 2 of exercise 8 (12.03.27) \ninepoint $\sum_{j=0}^{\lfloor\lg N\?\?\rfloor +2}$ \becomes $\sum_{j=1}^{\lfloor\lg N\?\?\rfloor +2}$ \endchange \bugonpage 3.426 line 6 of exercise 28 (12.10.30) \ninepoint $\bigl((x*x)*x\bigr)*\bigl((x*x)*x\bigr)$ \becomes $\bigl(x*(x*x)\bigr)*\bigl(x*(x*x)\bigr)$ \endchange \improvepage 3.513 line $-14$ (12.07.12) Section 2.3 \becomes Section II.3 \endchange \let\defaultpointsize=\ninepoint % get ready for answer pages \amendpage 3.598 line 12 of answer 10 (12.04.13) for some $k>1$ \becomes for some smallest $k>1$ \endchange \amendpage 3.601 in answer 22 (12.04.13) line 1: $0^k$ \becomes $0^p$\nl line 1: for some $k$ \becomes for some $p$\nl line 3: the number $k$ \becomes the number $p$\nl line $-4$: $0^k$ \becomes $0^p$\nl line $-3$: $k!\,(n_1+\cdots+n_t-k)!$ \becomes $p!\,(n_1+\cdots+n_t-p)!$\nl line $-3$: $\scriptstyle p_1+\cdots+p_t=k$ \becomes $\scriptstyle p_1+\cdots+p_t=p$\nl line $-2$: $k=0$ \becomes $p=0$ \endchange \amendpage 3.610 line 1 of answer 23 (12.07.28) {\sl Journal\/} \becomes {\sl Comptes Rendus Acad.\ Sci.\ \bf88} (Paris, 1879), 965--967; {\sl Journal\/} \endchange \improvepage 3.620 in answer 10 (13.04.29) line 2 after the program: time savings \becomes time saved\nl lines 5--6 after the program: not desirable \dots unless \becomes usually insignificant, since only $O(\log N)$ time is saved in that case unless \endchange \bugonpage 3.629 line {\it23} of the program in answer 12 (12.06.06) \.{J4N} \.{4B} \ \becomes \ \.{J4N} \.{8B} \endchange \bugonpage 3.660 line 9 of answer 23 (11.02.26) $x_{11}\gets 1$ \becomes $x_{11}\gets 0$ \endchange \amendpage 3.669 line $-3$ of answer 27 (11.12.18) 103--115. The fact \becomes 103--115; see also B.~E. Tenner, {\sl Annals of Combinatorics\/ \bf11} (2007), 101--114. The fact \endchange \amendpage 3.677 line 2 of answer 11 (13.01.20) sequence. \becomes sequence; hence the probability is 1/2, given that $\.{LASTKEY}\ne\infty$. \endchange \bugonpage 3.730 line 2 of step A7 (12.10.02) \.{TABLE[$i$]} \becomes \.{TABLE[$j$]} \endchange \let\defaultpointsize=\tenpoint % begin appendices \amendpage 3.753 through page 755 (12.04.07) [replace the notation $(R\Relbar\joinrel\joinrel\joinrel\Rightarrow x;\;y)$ by $(R{?}\ x{:}\ y)$ in eleven places] \endchange \amendpage 3.757 new entries for Appendix C (11.04.17) \ninepoint\noindent Program 5.2.1D$'$, 620.\nl Program 6.1S$'$, 702. \endchange \bugonpage 3.757 and 758 in Appendix C (11.04.17) \ninepoint\noindent Theorem 5.1.2C, 28--29.\nl Algorithm 5.2.2R, 123, 125.\nl Algorithm 5.4.2A, 267.\nl Program 6.2.3A, 464--466.\nl [also delete the first entry for Program 5.2C] \endchange \expandafter\ifx\csname indexeject\endcsname\relax\else\vfill\eject\fi \amendpage 3.759 and following (11.01.01) Miscellaneous changes to the existing index of Volume~3 are collected here, including corrections and amendments to the old entries as well as new entries that are occasioned by the new material. Thus, the lines of the full index that have changed serve also as an index to the present document. However, when a correction or amendment has caused an old index entry to be deleted, the deletion is usually not indicated. \input exotic \begindoublecolumns \indexformat \gdef\Uni1.08:{\bitmap24:1.08:} \hangindent 2em Chebyshev (= Tschebyscheff), Pafnutii Lvovich ({\rus Chebyshebp2, Pafnut{\char12}i0 Lp1vovichp2} = {\rus Chebyshev, Pafnutii0 Lp1vovich}), 395. % 30th $e$ (base of natural logarithms), 41, 526, 748--749, 755. % 30th Exact cover problem, 721. % 30th Olson, Charles Arthur, 544. % 30th Uzgalis, Robert Charles, 482, 490. % 30th Variance, different notions of, 709, 735, 742. %30th Wobbles, 133, 636, 727. % 29th \vfill \enddoublecolumns \endchange \bye [The next printing will be the 31st.] not mentioned above: page 620, I improved the illustration in answer 11 check 7.5.1 |reg-bp-match| = E ARTICLES "TO APPEAR" THAT ARE STILL PENDING: