There are a number of typos in the 1992 version of Sedgewick, "Algorithms in C++." The ones that I (BFC) have found are listed below. - p.26, line 10: "delete stack" -> "delete [] stack" This code was correct in an earlier version of C++. - p. 77, lines 7, -8 & -1: "$C_1 = 0$" -> "$C_1 = 1$" - p. 78, line 12: "$C_1 = 0$" -> "$C_1 = 1$" - p.27, lines -11 & -10: "save" -> "acc" - p. 147, line 12: "delete a" --> "delete [] a" - p. 150, line -8: "a[k/2] <= v" --> a[k/2] < v" This is not an error, just that no action is necessary or desirable when equality holds. - p. 160, line 20: "delete a; delete p; delete info" --> " delete [] a; delete [] p; delete [] info" - p. 195, line 17: "delete a" -> "delete [] a" - p. 279, line -16: "i -= j-1;" --> "i -= j;" - pp. 279-281: There are several errors in the section on the Brute-Force Algorithm and the beginning of the next section on the Knuth-Morris-Pratt Algorithm (where the brute-force algorithm is discussed more). All of these errors seem to follow from the fact that the code for the brute-force algorihm is not the code being discussed. Instead the book seems to be discussing code like the following: int brutesearch(char* const p, char* const a) { int i = 0, j = 0, M = strlen(p), N = strlen(a); while ( j < M && i < N) if (a[i] == p[j]) {i++; j++;} else {i -= j-1; j = 0;} if (j==M) return i-M; else return N; } - p. 283, line 1: "initnext(char *p)" --> "void initnext(char *p)" - p. 283, initnext() function: On the last past of the loop, in the increments, i is set to M and then next[M] is set to j, in error, as there is no Mth position in the array next. - p. 286, line -20: "next[2] is 7" --> "next[3] is 7" - p. 288, line 7: In the for loop "j > 0" --> "j >= 0). - p. 288, line 15: "return n" --> "return ++i" - p. 294, line -7: (1 + 01)*(0 + 1) --> (1 + 01)* + (1 + 01)*0 - p. 301: The program on this page contains a number of errors. Two examples: (1) 0 should be a correct answer indicating that a match of the empty string occurred. Suggest returning -1 to indicate that no match occurred. (2) the program does not work for the simplest machine, i.e., one that matches a single character, say A. The file "composer:~caviness/cis320/95Fall/sedgewick-code/match.cc" contains a correct version. The file "sedgewick-code/match-ling.cc" contains an analogous version that matches the longest possible substring in the input string. The best way to understand all this code is to start with a recursive version. Such a program, that makes matches of maximal length, is in the file "sedgewick-code/findmatch.cc" ------------------------------------------------------------ This information is in the file composer:~caviness/cis320/95Fall/sedgewick-typos