Errata List for "The Algorithm Design Manual (2nd Edition)" by Steven Skiena Last addition: May 7, 2013 Non-trivial errata are denoted with a (*). I include a separate section at the end for commentaries -- additional suggestions / clarifications suggested by readers which are not really errata. ============================================================================ Fresh Errata (now with Section descriptions for e-Book readers): Page 6, paragraph 3, line 9 (Section 1.1) "...before returning at the rightmost point." should be "...before returning at the leftmost point." Page 24, Figure 24 (Section 1.6) Adding commas between the digits would make it clearer Page 26, line 5 (Section 1.6) -- Replacing {2,3,4} by {2,4,5} might offer a more direct connection to the reasoning underlying the caption of figure 1.10. (which is updated in figure 1.11) Page 46, line -17 (Section 2.6): "this definition is the same" could be "this equivalence is the same" (*) Page 55, line -10 (Section 2.9.1) "a d-dimensional hypercube of length n^(1/d) on each side has volume d." should be "a d-dimensional hypercube of length n^(1/d) on each side has volume n." Page 67, line -18 (Section 3.1) The $\lg n$s in the formula should be written as $\lceil \lg n \rceil$. (*) Page 105, line 10 (Section 4.1): "polygon of smallest area" should be either "convex polygon of smallest area" or "polygon of smallest perimeter" Page 129, line 19 (Section 4.7): "We could sort sorting" should be "We could sort" Page 131, Line -7: (Section 4.8): The correct link to the sorting benchmark is: http://sortbenchmark.org/. Page 232, line -6 (Section 7.1) : "elements of vector a from a complete solution" -> "elements of vector a form a complete solution". (*) Page 256, formula (Section 7.5.3): The external negative sign on the equation reverses the condition. It should be: e^((C(Si) - C(S[i+1]))/kT) >= r Page 263, Fig. 7.12 (Section 7.7): Prefix GA and suffix AA should yield GAAA not GAAG. (*) Page 320, line -3 (Section 9.2.2): the last step of the algorithm "Longest Increasing Subsequence" has two costs "c_del" and no "c_sub", I think one of the "c_del" should be changed to a "c_sub". (*) Page 320, line 6 of paragraph 9.2.2 (Section 9.2.2): ", and substitution (c_del)" -> ", and substitution (c_sub)". (*) Page 428, line -12 (Section 13.10): a "b" is missing in the right hand side of the formula. Page 435, line 4 (Chapter 14 intro): "fasciles" -> "fascicles". (*) Page 457, line -12 (Section 14.6): "a_i <= 1 + max(a_1, ..., a_i)" should be "a_i <= 1 + max(a_1, ..., a_{i-1})". (*) Page 491, shortest path in a DAG recurrence (Section 15.4): $(x,i)$ should be $(i,j)$, so it reads: $d(s, j) = \min_{(i, j) \in E} { d(s, i) + w(i, j) }$ Page 552 lines 24 and 25 (Section 15.12): "... graph $h$ with the names of vertices of graph $g$ ..." should be "... graph $H$ with the names of vertices of graph $G$ ...". Page 522, line 3 in Notes (Section 15.12): "Fary's" -> "Fáry's" (*) Page 573, line 14 (Section 17.3): The Delauney triangulation "maximizes the minimum angle", *not* "minimizes the maximum angle". Page 620, line 1 of the first bullet in the bullet list (Chapter 18 intro): "To my taste, this remains is the best introduction to string algorithms." should be "To my taste, this remains the best introduction to string algorithms." Page 658, line 8 (Section 19.1.1): "Max-Planck-Instutut" -> "Max-Planck-Institut" Page 695, (Bibliography) [MV99]: "econometical" -> "econometric". /* All errata below *should* have been corrected in the revised printing */ Page viii, line -3 -- add a space after http://www.cs.sunysb.edu/~algorith Page 10, line -5 -- change "mutally" to "mutually" (*) Page 14, line 5: "reducing the number of overlapped segments from four to two" --> "reducing the number of overlapped segments from five to two" Page 17, line 12: "at the end this chapter" --> "at the end of this chapter" Page 17, line 14: "Summation formula" --> "Summation formulae" Page 17, line -5 -- change "We already encountered arithmetic progressions when we saw" to "We will encounter the arithmetic progression" (*) Page 17, line -8 - the pairing argument of the summation only works for even values of $n$. It can be extended by computing twice the desired sum as the middle sum, with the upper limit changed from n/2 to n = twice the expression on the right, that is, n(n+1), and then follow this with one more line of text: "so that (desired sum) = n(n+1)/2." (*) Page 18 line 8 -- the sum of a geometric series should be "(a^(n+1) - 1)/(a - 1)" instead of "a*(a^(n+1) - 1)/(a - 1)" Page 21, Figure 1.9: Permutations -- NOT an erratum!! {4,1,5,2,3} -> 4 + {1,4,2,3} is supposed to capture the induced permutation left after removing the head. {1,5,2,3} is not a permutation of 1 to 4. Another example would be {3,1,5,4,2} -> 3 + {1,4,3,2}. Any permutation is an arrangement of the number 1..n, so deleting the first element renumbers the rest. Page 27, line 3 - Change "Corman" to "Cormen". Page 27, line -2 -- change the sentence to "That is, give an $S$ and $T$ where the algorithm does not find a solution which leaves the knapsack completely full, even though a full-knapsack solution exists." (* Kindle only) Page 35 -- The Kindle edition has certain >= signs turned into equal sighns, as shown in http://www.nsds.net/adm_kindle_bugreport.htm (*) Page 36, fifth inequality (Omega(n^3)) -- "because I choose c=3" should be "because I choose c=1" (*) Page 43, line 3 - "S(n) = >=": extra = should be deleted. (*) Page 45, code at bottom -- There is an inconsistency between the variable names x,y,z in the problem definition and the program fragment. The easiest resolution is to reverse the variable names y and z in the program fragment (lines -3 and -5) Page 47, caption of figure 2.7: "per node as d^h leaves": 'as' should be 'has'. Page 49, last line of Figure 2.8 -- (Q) should be (S) (*) Page 50, line -5 -- "dividing" should be "multiplying". Page 54, line -5 - "Ackerman" should be "Ackermann" Page 63, exercise 2-38 -- 26,397 should be 26,797. Page 64, exercise 2-50: Perhaps Ramanujan numbers should be called "Ramanujan-Hardy" numbers. Page 64, line 18: The comma in the beginning of the line should be moved to the end of the preceding line. Page 68, line 2: "declared at compiler time" --> "declared at compile time" Page 68, line 4: "address (i.e. , pointer) of a particular variable" --> "address of (i.e., pointer to) a particular variable" Page 69, line -5: "the place pointed to l" --> "the place pointed to by l" Page 70, line -13: The comment "splice out out list" should be "splice out of list" (*) Page 70, line 4 -- The error message is too strong a side-effect since several applications (including delete_list) stumble upon it naturally. Downgrade the error to a comment. Page 73, line -3 -- "reveal" should be "reveals". Page 73, line 6 -- "Prececessor(D, k) or Successor(D,k)" --> "Prececessor(D, x) or Successor(D,x)" Page 78, line -14 -- "uniquely identities" should be "uniquely identifies" Page 81, line -13 -- "(p)" is unnecessary. Page 83, problem part 3 -- we can drop "search" for the allowable operations. (*) Page 85, line 4 -- the clause "followed by search" is unnecessary. Page 98, line 3 of first para: "has to more" should be "has led to more" (*) Page 101, line 2 -- change "less than $y$" to "less than $k$". (*) Page 110, line -1 -- change $n/2$ to $k/2$ (*) Page 115, line -10 -- the loop could/should go from "q->n/2 to 1" instead of "q->n to 1", although what is there works correctly. Page 117, line 3 from top -- "if ((count <= 0) || ...": The opening parenthesis of if() is not closed. Page 122 -- the code has a declaration of a "int i; /*counter*/" that is actually never used there. Page 126, line 7 -- "lies is in the center" should be "lies in the center" Page 129, 3rd para lines 1-2: "where a properly implemented quicksort is implemented well" should be "when quicksort is implemented well" (*) Page 138, in the diagram of Figure 4.9, the description of width at the bottom of the diagram says: width = a^(logb(n)) = n^(logb(b)) It should say: width = a^(logb(n)) = n^(logb(a)) (*) Page 140, problem 4-9: "they appear more than once" should be "they appear exactly once" (*) Page 144, problem 4-45 -- change the second sentence to the following with corrections within **'s: "You are given the index positions where these words occur in **the document**, such as word1: (1,4,5), word2: (*3*,9,10), and word3: (*2*,6, 15). Page 156, line 10 -- change "handled better to regular" to "handled regular". (*) Page 169-170, psuedocode -- the "time = time + 1" line should be before the "entry[u] = time" one (as it is the case in the corresponding C code) (*) Page 171, line -2 -- The dfs code has a bug, where each tree edge is processed twice in undirected graphs. The test needs to be strengthed to be: else if (((!processed[y]) && (parent[v]!=y)) || (g->directed)) (*) Page 173, line 2 -- Delete the word "not", ie. "The issue is also easy if y has *not* been completely processed" should be "The issue is also easy if y has been completely processed". (*) Page 173, process_edge procedure -- the correct test should be if (discovered[y] && (parent[x] != y)) { /* found back edge */ Page 174, second to last line -- "vertices 2 and 6" should read "vertices 5 and 6" (*) Page 175, line 13 -- it is clearer to say: "denote the earliest reachable ancestor of vertex v, meaning the oldest ancestor of v that we can reach from a descendant of $v$. by using a back edge." (*) Page 177, process-vertex-late code -- There is a problem with published code when the root is of degree one, as in node 6 of Figure 5.12, because no root testing is applied in the bridge cutnode case. A fix is: root = (parent[parent[v]] < 1); /* test if parent[v] is root */ if (!root) { if (reachable_ancestor[v] == parent[v]) { printf("parent articulation vertex: %d \n",parent[v]); } if (reachable_ancestor[v] == v) { printf("bridge articulation vertex: %d \n",parent[v]); if (tree_out_degree[v] > 0) /* test if v is not a leaf */ printf("bridge articulation vertex: %d \n",v); } } Page 177, last line -- "minor" should be "appropriate" and "the reachable_ancestor function" should be "process_late_vertex". Page 178, Figure 5.14 -- the upgoing cross edge on right cannot appear in a DFS, but can in a BFS. (*) Pg 179, line 4 of the DFS-Graph(G) algorithm: The line "for each vertex $u \in V[G]$ do" should be indented left (to align with the first for-loop line). Page 183, line 6 -- "peal" should be "peel". (*) Page 184, process-vertex-late code -- There is a problem with published code when the component has to be popped at the root node, such as when the root is of degree one. A fix is: process_vertex_late(int v) { /*printf("exit vertex %d at time %d\n",v, exit_time[v]);*/ if (low[v] == v) { /* edge (parent[v],v) cuts off scc */ /*printf("strong commonent started backtracking from %d\n",v);*/ pop_component(v); } if (parent[v] > 0) { /* only if v is not the root */ if (entry_time[low[v]] < entry_time[low[parent[v]]]) { low[parent[v]] = low[v]; } } } (*) Page 185, Exercise 5.2 -- this graph is not acyclic. Reverse the edge (F,H). (*) Pg 209, line 3: "For undirected graphs, this would be breadth-first search tree": "undirected" should be "unweighted". (*) Pg 210, line 9 from bottom: "provided MAXINT is less than the diameter of your graph": "less than" should be "greater than". (*) Page 227, exercise 6-11: The running time should be O(m + n \log k). Page 250, line 14 from bottom: "there is a 1/n chance of getting": The 1/n should be 1/(n-1). Page 250, line 12 from bottom: "n times more often": Again, the n should be n-1. (*) Page 279. Figure 8.3. table on the right-hand side -- Cell [2][1] must be 2 not 1. Also, should use n / k for consistancy instead of m / n. Page 280, program -- should use n, k for consistancy instead of n,m. (*) Page 282, program -- note that this routine uses the same index convention reported on the top of Page 284. Page 283, program -- Yes, the loops only through strlen(s)-1 times: recall that the strings have been prepended by blanks under the index convention above. (*) Page 291, Table. The Li underneath Si 3 should be 2. Page 297, top paragraph shouldn't be indented. (*) Page 299, the big display after second para: In the subscript for the second bigvee, the "i=k" should be "k=i". Page 313, problem 8-14 -- "dynamic programming" should be "dynamic programming algorithm". Page 314, problem 8-20 -- maybe $k=12$ for standard phones today. Page 317, line 13 -- "be called be tough" should be "be called tough" (*) Page 317, line -10: the italic "problem" and "instance" should be swapped. Page 319, before 9.2.1 Closest Pair subheading: "The overall running time is the time needed to perform the reduction plus that (to) solve the b instance" Page 326, "Output: Can a subset of at least k mutually nonoverlapping interval sets (which can) be selected from I?" Remove parenthetical words. Page 327, before 9.3.3 Clique: "Thus, general movie scheduling must be (hard) as hard as independent set, and hence NP-complete." Remove parenthetical word. Page 329, third paragraph: "Literally every top-notch algorithm expert in the world (and countless lesser lights) have directly or indirectly tried to come up with..." have -> has (*) Page 344, line 16 -- "hard to get close to the answer" should be "hard to get the exact answer". Page 344, line 17 -- "probably" should be "provably" Page 381, line 10 -- "seems too be" should be "seems to be". Page 401, line 10 -- "computes the product" should be "to compute the product" (*) Page 401, line 16 -- "A[i, k] * A[k, j]" should be "A[i, k] * B[k, j]" Page 431, Problem description -- a negative sign is missing before the 2 pi in the exponent of the DFT definition. (*) Page 528, Problem description -- "either x notin E or y notin E" should be "either x notin S or y notin S". The whole description is clumsy -- for no edge can both its endpoints be in the indepedent set S. (*) Page 623, caption of Figure 18.1 -- "selecting subsets 1 and 3 or 2 and 4 (r)." should be "selecting subsets 1 and 3 or 2 and 3 (r)." Page 663, line -2, "it's" should be "its". Page 686, Reference [HUW02] -- Add "Tech. Report AURORA TR2002-08, Vienna University of Technology, 2002.". Back cover, bullet -3 right -- change "Exercises points" to "Exercises point" ============================================================================ Errata since submitting the proofs for the corrected reprint: (*) Page 110, line -12: "we will store the $2^l$ keys of the $l$th level" should be "we will store the $2^{l-1}$ keys of the $l$th level". Page 199, Figure 6.5: It is more consistant with the implementation for the zeros in the right figure to be the index i, so the zeros should be replaced by 1, 3, and 4. (*) Page 281, right before the code: The description for the formula D[i-1,j]+1 should be the delete operation, and the description for the formula D[i,j-1]+1 should be the insert operation. The descriptions are inverted. (*) Page 297, first line after the figure: the formula states that the summation equals p[j]-p[k], the equality should read p[j]-p[i-1] Page 654 (right figure): The real shortest superstring is ADABRACADA, not ABRACADABRA. ================================================================= Commentaries ============ Page 72: Perhaps it would be more consistent to use capital letters for all container variables? Currently stacks and queues are lower-case, but dictionaries are upper-case. And to always put the container parameter first and the item/key parameter second? Currently stacks and queues are second in Push and Enqueue, while dictionaries are first in all their operations. Page 76, last paragraph: There's really no need for an extra sweep over the list to maintain the pointer to the last item, as the deletion already requires that we get a pointer to the second to last item in order to un-link the last item. Pg 111, the two C function definitions: It might be nice to specify the function definitions that these functions return 'int'. Pg 199, figure 6.5 right: Root nodes in this figure are indicated via "0", but in the algorithm on the next page, the representation parent[x] = x is used. Perhaps this figure could be changes to match up with that representation. - p 397, line 10: an equally good reason to avoid inv(A) is that it is less numerically stable. See Sec 14.1 of http://www.maths.manchester.ac.uk/~higham/asna @Book{Higham:2002:ASN, author = "Nicholas J. Higham", title = "Accuracy and Stability of Numerical Algorithms", publisher = "Society for Industrial and Applied Mathematics", address = "Philadelphia, PA, USA", edition = "Second", year = "2002", pages = "xxx+680", ISBN = "0-89871-521-0" } - p 397, line 15: you can delete "apparently". It's indubitably true. - p 402, third para from bottom. You should really refer to the level 3 BLAS here, not LAPACK. I'm not sure that Alg 601 is used nowadays. More recent is http://www-users.cs.umn.edu/~saad/software/SPARSKIT/sparskit.html - p 433: I'd suggest citing the classic book by Van Loan @book{vanl92a, author = "Van Loan, Charles F.", title = "Computational Frameworks for the Fast {Fourier} Transform", publisher = pub-SIAM, address = pub-SIAM:adr, year = 1992, pages = "xiii+273", isbn = "0-89871-285-8", } @String{pub-SIAM = "Society for Industrial and Applied Mathematics"} @String{pub-SIAM:adr = "Philadelphia, PA, USA"}