Errata for book Classic Data Structures in C++ by Tim Budd, published by Addison Wesley. last updated Monday, March 27, 1995 Items fixed in second printing have not been listed. These can be found in the file ``errata1''. negative numbers count from bottom of page, positive from top TYPOS -- (minor errors) ------------------------------------------------ Page 47, cout statement is reversed from print statements earlier on page. Page 49, line 17, nine => ten Page 54, line 7, small thann => smaller than or equal to Page 77, labels on chart are wrong (should refer to figures 3.5 and 3.6) Page 112, line -8, <= count should be < count Page 120, line -10, first mat++ should be mat.init() Page 140, table 5.1, description of queue is confusing Page 144, lines 10 and -18, T & initialvalue should be const T & initialvalue Also Page 145, line -18, Page 147, line -8, Page 150, line -6, Page 151, line -17 Page 158, line 21, "data byte must" not data type Page 161, line 11 and 15, color should be colors Page 162, line -9, dat; should be dat(blue); Page 165 166, calls on rows() and columns() at bottom of 165 and top of 166 should be numberRows() and numberColumns() Page 174, 2nd line from bottom, Appendix C, not Appendex B Page 178, line 14, page 15 not page 178 Page 179, line 2 of text, overloaded should be overridden Page 180 == see comments on ``keeping up with C++'' page 185, enumvector should be enumVector (upper case v) Page 234, 2nd line from bottom, page 234 should be page 84 Page 237, line 10, wrong font for class rational Page 243, exercise 20, should be chapter 6, ex 12, page 174 Page 265, line 6, bottom left corner should be bottom right corner Page 286, line 1, copy() should be virtual Page 290, line 1, page 290 should be page 248 Page 299, as much space as the list itself, should be tree itself Page 302, line -12, data ares => data areas Page 327, line 3, private => protected Page 334, picture at bottom, 2: should be 2:2 Page 337, line 1, the method is class avlNode should be the method is from class avlNode Page 338, in box, AVLTree should be avlTree Page 350, near bottom, see references at end of section, should be end of chapter Page 352, algorithm 11.1 should be algorithm shown in figure 11.1. Page 353, exercise 11, see Asymbpotic Analysis should be Asymptotic Execution Page 369, destructor should be declared as virtual Page 377, line 12, chars should be chairs Page 384, exercise 12, page 384 should be page 308 Page 396, 8 line from bottom, page 396 should be page 339 Page 398, the text program should be the test program Page 404, line 16, second column tree sort should be bucket sort Page 416, discussion of inheritance is misleading. There is no class Set (or set). Page 422, line 2, dictionary to correctly should be dictionary of correctly Page 425, page 425 should be page 388 Page 427, reference to nil should be reference to null Page 427, includes method should be includesKey method (in text, 5 lines from bottom) Page 427, line -13, itr() == key => itr()->key() == key Page 447, line 1, vector data type should be vertex data type Page 450, line -4, labeledVertex & should be labeledVertex & Page 455, figure, label on state 1 should be ``Even b''. Page 468, 2nd paragraph, should be slash char, not backslash char Page 471, comment in code, heap sort should be merge sort Page 484, exercise 7, page 484 should be page 447 ERRORS -- (more major blunders) -------------------------------------------- Page 106 -- note that += doesn't work if you catenate a string to itself. Here is a fix suggested by Tom Anistasio void string::operator += (const string & val) { // append argument to end of current string // if there isn't space, make new buffer int combinedLength = length() + val.length(); char * newbuffer = 0; if (combinedLength >= bufferlength) { newbuffer = new char [1 + combinedLength]; assert(newbuffer != 0); bufferlength = 1 + combinedLength; } else newbuffer = buffer; // copy over old values for (int i = 0; buffer[i] != '\0'; i++) newbuffer[i] = buffer[i]; newbuffer[i] = '\0'; i = CstringLength(buffer); // catenate val on end of current string for (int j = 0; val.buffer[j] != '\0'; j++) newbuffer[i++] = val.buffer[j]; newbuffer[i] = '\0'; if (newbuffer != buffer) // new buffer was allocated delete [] buffer; // so delete the old buffer buffer = newbuffer; } Page 308, question 11 is open -- doesn't have an answer. Should perhaps have read ``Can you observe any pattern that could be used in an algorithm?'' Page 459, questions 4 and 6 are ambiguous if you don't specify a starting vertex. Page 460, question 6 is answered in the text. KEEPING UP WITH C++ ------------------------- C++ continues to be a moving target. Not all C++ compilers accept the same language. This makes it difficult to write truly portable code. Major problems involve the following: * the question of when to write foo and when to write simply foo in a templated class -- rules seem to continually change and different compilers treat this differently * the issue of whether the ++ operator can be used both as x++ and as ++x if only one declaration is given. There seems to have been a progression in this regard. Initially (when the book was being written) there was only one operator, used for both. Then the trick of using an operator with an extra int paramater was introduced for postincrement, but if only one was defined then it could be used for both pre and postincrement. Then warnings were introduced if only one operator was defined. Finally, compilers now will reject the use of postincrement (as with iterators) if only the preincrement operator is defined. * copy constructors -- many compilers now seem to generate default copy constructors, even if they are not used. g++ uses the assignment operator for this, which causes problems with iterators, which redefined this operator. Therefore all iterators now need to define explicit copy constructors * references -- formerly you could make references to functions, now it is only possible to create pointers to functions. G++ also appears to get confused sometimes when references are used in data structures. if you are attempting to get the sources to work on a compiler that I have not used before then some experimentation may be necessary. KUDOS --- The following individuals have found one or more of the above errors, many thanks to them. Mehdi Abedinejad, Boston University Tom Anastasio, University of Maryland, Baltimore County Owen L. Astrachan, Duke University Jon Beck, Northeast Missouri State University Jan Derriks, Hogeschool van Amsterdam, Technische Maritime Faculteit. Yasushi Kambayashi, Shonan Junior College, Japan Wolfgang Kramarczyk, Max-Planck-Institut, Germany Stan Kwasny, Washington University, Saint-Louis Walter Maner, Bowling Green State University, Ohio Donald McLean, University of Maryland, BC Stephane Riviere, iMAGIN/IMAG Rick Zaccone, Bucknell University