% CHANGES TO FASCICLE V4F3 OF THE ART OF COMPUTER PROGRAMMING % % Copyright (C) 2005,2006,2007,2008 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 err4f3" \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{\hss\cleaders\hbox{\raise3pt\hbox{\manfnt\char'36}}\hfill \titlefont\ #1\ \cleaders\hbox{\raise3pt\hbox{\manfnt\char'36}}\hfill\hss}} \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 4 FASCICLE 3} \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~4, Fascicle~3, since it was first printed in 2005. \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 \beginconstruction The ultimate, glorious, future editions of Volumes 1--5 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~4 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, June 2005} \bigskip \bigskip {\quoteformat For a work of such scope as this, the first word of the author should be an apology for what is doubtless the too ambitious effort of a single writer. \author EDWARD W. BYRN (1900) % The Progress of Invention in the Nineteenth Century, page i \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 4 FASCICLE 3 %%%%%%%%%%%%%%%%%%%%%%%%%%% \def\lhead{\kern-12ptCHANGES TO V4F3: GENERATING ALL COMBINATIONS AND PARTITIONS} \def\rhead{CHANGES TO V4F3: GENERATING ALL COMBINATIONS AND PARTITIONS\kern-12pt} \titlepage \volheadline{GENERATING ALL COMBINATIONS AND PARTITIONS} % the fascicle title \bigskip \rightline{Copyright \copyright\ 2005, 2006, 2007, 2008, 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 \improvepage 4f3.iv line $-12$ (05.12.04) indices \becomes indexes \endchange \amendpage 4f3.0 replacement for lines 3 and 4 (07.06.13) \beginconstruction The opening sections of this chapter will appear in Volume~4, Fascicle~0, and Volume~4, Fascicle~1, planned for publication in 2007 and 2008.\par\endgroup \endchange \improvepage 4f3.1 line $-8$ (08.04.21) The latter representation \becomes The string representation \endchange \bugonpage 4f3.2 in the running headline {(also on pages 4, 6, 8, \dots!)} (05.09.07) \eightpoint (F2) \becomes (F3) \endchange \amendpage 4f3.4 line 10 (06.10.18) 7.1--00 \becomes 7.1.3--20 \endchange \improvepage 4f3.4 line $-7$ (05.09.17) repeat until $c_j+1\ne c_{j+1}$. \becomes eventually the condition $c_j+1\ne c_{j+1}$ will occur. \endchange \bugonpage 4f3.7 in {\eq(23)} (06.07.31) $w_1\ge w_0;$ \becomes $w_1\ge w_0\ge0@;$ \endchange \amendpage 4f3.8 lines $-13$ and $-12$ (06.03.24) discovered by D.~T. Tang \becomes discovered by J.~E. Miller in her Ph.D. thesis (Columbia University, 1971), then independently by D.~T. Tang \endchange \improvepage 4f3.8 near the bottom (06.10.23) lines $-3$ and $-1$: increasing \becomes nondecreasing\nl line $-2$: {\it decreasing} \becomes non{\it increasing} \endchange \improvepage 4f3.13 in steps C4 and C6 (08.04.21) $r=j>1$ \becomes $r=j$ and $j>1$ \endchange \bugonpage 4f3.17 {(and throughout the fascicle!)} (08.04.04) \ninepoint{\bf Fig.\ 26} \becomes {\bf Fig.\ 46} [and all figure numbers need to increased by 20] \endchange \improvepage 4f3.20 line $-2$ (05.08.07) in cross order \becomes in increasing cross order \endchange \amendpage 4f3.27 exercise 21 (06.03.24) \ninepoint Prove \becomes (Joan E. Miller, 1971.) Prove \endchange \bugonpage 4f3.35 in the running headline (05.10.25) {\eightrm PARTITIONS \becomes COMBINATIONS} \endchange \bugonpage 4f3.35 line 3 (06.03.07) $11001000,\,11001001$ \becomes $11001000,\,11001010,\,11001001$ \endchange \amendpage 4f3.35 new exercise (06.08.09) \ninepoint{\advance\parindent by4pt \EX111. [M26] (P. Erd\H{o}s, C. Ko, and R. Rado.) Suppose $A$ is a set of $r$-combinations of an $n$-set, with $\alpha\cap\beta \ne\emptyset$ whenever $\alpha,\beta\in A$. Show that $\vert A\vert\le {n-1\choose r-1}$, if $r\le n/2$. \em Hint: Consider $\del^{n-2r}B$, where $B$ is the set of complements of~$A$. \par} \endchange \amendpage 4f3.36 line 4 (07.08.21) (see Table 1). All twelve of Stanley's \becomes \nl (see Table 1), based on a series of lectures by Gian-Carlo Rota. All twelve of these \endchange \amendpage 4f3.37 bottom line (05.10.24) 52]: \becomes 52], and pad the array with 1s as suggested by A.~Zoghbi and I.~Stojmenovi\'c [{\sl International Journal of Computer Math.\ \bf70} (1998), 319--332]: \endchange \amendpage 4f3.38 line 3 (06.05.29) $n\ge1$. \becomes $n\ge1$. The value of $a_0$ is also set to zero. \endchange \amendpage 4f3.38 replacement for step P1 (05.10.24) \algindentset{P1}% \algstep P1. [Initialize.] Set $a_m\gets1$ for $n\ge m>1$. Then set $m\gets1$ and $a_0\gets0$. \endchange \amendpage 4f3.38 replacement for step P4 (05.10.24) \algstep P4. [Change 2 to $1{+}1$.] Set $a_q\gets1$, $q\gets q-1$, $m\gets m+1$, and return to P3. (At this point we have $a_k=1$ for $q%% Unicode char "67ef \GC68:72:-5:59% G5357 <000000000000000e00000000000000003f00000000000000007f801fffffffffffffffc0% 0fffffffffffffffe007fffffffffffffff00200001fc000003ff00000001fc000003fc0% 0000001f8000003f000000003f8000003f000000003f8000003f000000003f8000003f00% 0000003f8000003f000000003f8000007f000000003f0000007f000000003f0000007f00% 0000007f0000007e000000007e0000007e00000000fe000000fe00000000fc000000fe00% 000001fc000001fe00000001f8000001fc00000003f8000001fc00000003f0000001f800% 000007f001f803f80000000fe001ff83f00000000fc0001ffff00000001f800007ffe000% 00003f800003ffe00000007f000001ffc00000007e000000ff80000000fc000000ff0000% 0001fc0000007e00000003f80000004000000007f0000000000000000fe000000000e000% 001ffc00000001f800003e7f00000003fc00007c7ffffffffffe0001f07ffffffffffe00% 07e07ffffffffffe000f007e00000001f8003c007e00000001f800e0007e00000001f800% c0007e00000001f80000007e00000001f80000007e00000001f80000007e00000001f800% 00007e00000001f80000007e00000001f80000007e00000001f80000007e00000001f800% 00007e00000001f80000007e00000001f80000007e00000001f80000007e00000001f800% 00007e00000001f80000007e00000001f80000007e00000001f80000007e00000001f800% 00007ffffffffff80000007ffffffffff80000007ffffffffff80000007e00000001f800% 00007e00000001f80000007e00000001f80000007e00000001f80000007e00000001f800% 00007e00000001f8000000fe00000001f8000000fc00000001f8000000fc00000001f000% >%% Unicode char "53ec ), 35. % 2nd Left-child/right-sibling links, 90. % 2nd Lenin, Vladimir Ilyich ({\rus Lenin, Vladimir Ilp1ich}), 11. % 2nd Littlewood, Dudley Ernest, 120. % 2nd Littlewood, John Edensor, 121. % 2nd Miller, Joan Elizabeth, 8, 27. % 2nd Notational conventions:\indexnoperiod % 2nd \sub $\Gamma^R$ (reversal), 8. % 2nd \sub ${n\parts m}^{\mathstrut}_{\mathstrut}$ (the number of partitions of~$n$ into exactly $m$~parts), 38. % 2nd Rado, Richard, 35. % 2nd Rota, Gian-Carlo, 36. % 2nd Seth, Vikram ({\dn Evk\kern-.6em\hbox{\char2}\kern.6emm s\kern-0.8em\char3W}), ii, 83. % 2nd Sideways heap, 90. % 2nd Stojmenovi\'c, Ivan Dan\v{c}a ({\rus Stojmenovits1, Ivan Dancha}), 37. % 2nd Ulyanov, Vladimir Ilyich ({\rus Ulp1yanov, Vladimir Ilp1ich}), 11. % 2nd Zoghbi, Antoine Chaiban \indexbreak ({\arab\Afy/\Amb/\Aigh/\Afz/\Ail/\Aa/ \An/\Afa/\Amb/\Amy/\Aish/ \An/\Afw/\Amtt/\Ain/\Aha/}), 37. % 2nd \vfill \enddoublecolumns \endchange \bye ******** I'm not sure yet about the Figure renumbering constant! ********** ******** (needs to be fixed also in err4f2 and err4f4) ******************** [The next printing will be the 2nd.] not listed above: page iii, The Stanford -> the Stanford page 2, new paragraph break near the bottom page 31, more complete list in lines 7 and 10 of exercise 62 page 35, improved wording in exercise 110 page 46, improved wording after (43), with reference to exercise 35 page 58, better wording in ex 55 line 2 pages 34, 35, 106--109: parindent is a tad too big on ex numbers > 99 page 96, "To" -> "Go to" in steps CB7, CB8 page 97, avoided clashes between lines in answer 49 I moved a line from page 99 to page 100 page 112, improved wording in answer 17(b) page 120, commas in step M5 Index entries for pi as random ex, shadow of binary string move from 35 to 34 check |gosper-hack|=20 in 7.1.3.ref, regarding page 4f3.4 ARTICLES "TO APPEAR" THAT ARE STILL PENDING: 7.2.1.4, Colthurst--Kleber paper on binary partitions [as of April 2007, Kleber's home page says it is still a work in progress]