Errata for the Book: | |
Classic Data Structures in Java | |
by Timothy A. Budd | |
Published by Addison-Wesley Longman |
Positive line numbers count from top of page, negative from bottom of page.
Chap | Page | line | Comment | Contributor |
---|---|---|---|---|
1 | 10 | -2 | n should be val, also on next page | (js) |
1 | 11 | 2 | printInt(out, n/10); // two parameters | (hs) |
1 | 11 | 3 | Missing right parenthesis | (hs) |
2 | 24 | -2 | integer=>int | (bb) |
2 | 27 | 20 | insertAndExtract => getAndSet | (js) |
2 | 33 | 7 | can invoked => can be invoked | (vk) |
2 | 37 | -18 | should extend Collection or Bag | |
2 | 37 | -18 | arguments could be Bag, not Set | |
2 | 39 | 7 | description backwards, -1 if left is smaller, not larger | (ms) |
2 | 47 | -10 | removeElement should not return anything | (js) |
3 | 55 | 1 | code doesn't work without default | (js) |
3 | 56 | -8 | printInt should have two arguments | (hs) |
3 | 59 | 4 | assert greater than, not >= | (brm) |
3 | 66 | Ex 6 | Should have first asked to prove time is O(2^n). | |
4 | 71 | 10-11 | for all and exists reversed, correct on p. 92 | (hs) |
4 | 77 | 19 | n2+n => n2-n | (em) |
4 | 80 | 12 | m[i,j] should be m[i][j] | (rb) |
5 | 114 | Ex 13 | Chapter 9? What was I thinking??? | |
6 | 119 | -15 | index should begin at 1, not 2 | (ms) |
6 | 121 | -12 | addElement(...) => addLast(...) (vectors don't have addElement) | (rs) |
6 | 125 | 3 | getLast throws ArrayIndexException, interface specifies NoSuchElementException | (rl) |
6 | 127 | Box | Visitor not in source? (see comments below) | (rm) |
6 | 147 | Ex 11 | 16 should be 26, so as to force two reallocations. | |
6 | 148 | Ex 14 | Problem is, this version of bubble sort IS stable | |
7 | 160 | code | should use comparator instead of equals (see below) | (mo) |
7 | 179 | Ex 2 | 10,000 should be 1,000 | |
8 | 193 | 1 | Insert should return new link (correct in code library) | (rm) |
8 | 202 | code | Variables x and y should be private | (dc) |
8 | 204 | -6 | class Asteroid is unnecessary | (dc) |
8 | 206 | 6 | extend => extends | (dc) |
8 | 214 | Ex 11 | Assume all elements are unique (much harder otherwise) | |
8 | 214 | PP 6.b | Can't clone the individual elements (see below) | (rm) |
9 | 228 | 4 | insert may be confusing (see below) | (eb) |
9 | 230 | code | use equals or compare (see below) | (mo) |
10 | 258 | Fig 5 | que is incongruous name for a stack | |
11 | 290 | Ex 6.h | addElement => addElementAt | (sdog) |
12 | 315 | 2 | constructor should be public | (sdog) |
12 | 316 | 12 | addList=>addLast | (sdog) |
12 | 319 | -8 | for consistency, should assign getfirst to variable | (ag) |
13 | 341 | 16 | need cast: current = (BinaryNode) stk.getLast(); | |
13 | 341 | 17 | recursive call needs guard, if (current.rightChild) != null | (js) |
14 | 348 | 16 | result=>res | (mo) |
14 | 349 | 3 | add stk.removeLast() | (mo) |
14 | 360 | getFirst | root.getFirst returns a node, need to get value | (ak) |
14 | 379 | Ex 6 | Exercise 6 is same as exercise 3 | |
14 | 381 | -10 | root is deleted=>current node is deleted | (jc) |
15 | 393 | -8 | need to add ``if (max != 0)'' before loop | (sdog) |
15 | 404 | -8 | less than should be less-or-equal | (dc) |
15 | 407 | 3 | DefaultComparator is now in java.util.DefaultComparator | |
17 | 464 | what to do with non-empty collections (see below) | (rm) | |
17 | 473 | Ex 4.c | Good luck. Doesn't parse | |
18 | 481 | Arguments to union/intersection could be any Bag | ||
18 | 489 | 2 | Can return immediately when sentinel is encountered | |
18 | 503 | Ex 10 | should ask first if subset is less than or less-than-equal | |
19 | 527 | Ex 2 | Question doesn't make sense since matrix is an interface not a class | |
19 | 527 | Ex 4 | Should give a hint (see below) | |
B | 573 | -1 | Comparator is now java.util.Comparator | |
B | 583 | 3 | DefaultComparator is now java.util.DefaultComparator | |
20 | 555 | Ex 7 | Need to specify a starting vertex | |
593 | Entry vistor unnecessary | (dc) |
This problem was pointed out by Ron Metoyer.
I have more control over the code than over the book, so I'll try to update these in real time as they come in. Here are things that have been spotted: