Errata, Third Printing (August 2009)


CHAPTER 1

p. 15, table

Printed: "AB" Hello" "2.5"
Fixed: "AB" "Hello" "2.5"
Reported by Swami Iyer, 05-Mar-11.

p. 39, Exercise 1.2.3

Printed: Suppose that a and b are int values.
Fixed: Suppose that a and b are boolean values.
Reported by Travis Perlee, 02-Mar-10.

p. 41, Exercise 1.2.22

Printed: x0 + v0t + g t2 / 2
Fixed: x0 + v0t - g t2 / 2
Reported by Ross Sowell, 13-Sep-11.

p. 43, Exercise 1.2.29

Printed: (14 + 2483 + (31*12) / 12) % 7 = 2500 % 7 = 1
Fixed: (14 + 2483 + (31*12) / 12) % 7 = 2528 % 7 = 1
Reported by Zhong Shao, 01-Jan-12.

p. 48

Printed: if (x > y) { int t = x; y = x; x = t; }
Fixed: if (x > y) { int t = x; x = y; y = t; }
Reported by Oliver Kullmann, 24-Sep-09.

p. 50

Printed: the statement block is executed five times until the sequence is broken
Fixed: the statement block is executed seven times until the sequence is broken
Reported by Petra Alm and Dirk Louis, 04-Sep-10.

p. 81, Exercise 1.3.26

Printed: (i <= N/i) instead of (i < N)
Fixed: (i < n) instead of (i <= n/i)
Reported by Petra Alm and Dirk Louis, 12-Sep-10.

p. 81, Exercise 1.3.36

Printed: double num = 1.0, dem = 1.0;
Fixed: double num = 1.0, den = 1.0;
Reported by Petra Alm and Dirk Louis, 12-Sep-10.

p. 92

Printed: for (int i = 0; i < suit.length; i++)
   for (int j = 0; j <
rank.length; j++)
      deck[
rank.length*i + j] = rank[i] + " of " + suit[j]
Fixed: for (int i = 0; i < rank.length; i++)
   for (int j = 0; j <
suit.length; j++)
      deck[
suit.length*i + j] = rank[i] + " of " + suit[j]
Reported by Kenneth Sloan, 31-Aug-10.

p. 98

Printed: // Generate random values in (0..N]
Fixed: // Generate random values in [0..N)
Reported by Clemens Schneider, 06-Apr-12.

p. 106

Printed: the column vector has M entries all equal to 1/M
the row vector has N entries all equal to 1/N
Fixed: the column vector has N entries all equal to 1/N
the row vector has M entries all equal to 1/M
Reported by Zhong Xiang, 04-Jul-11.



CHAPTER 2

p. 238

Printed: gcd(216, 24)
Fixed: gcd(216, 192)
Reported by Vitaly Nazarov, 02-Mar-11.

p. 236

Printed: σ2 = ((x0 - μ)2 + (x1 - μ)2 + ... + (xN-1 - μ)2)) / N-1
Fixed: σ2 = ((x0 - μ)2 + (x1 - μ)2 + ... + (xN-1 - μ)2) / N-1
Reported by Petra Alm and Dirk Louis, 02-Nov-10.

p. 238

Printed: StdStats (Program 2.2.3)
Fixed: StdStats (Program 2.2.4)
Reported by Zhou Changling, 02-Sep-09.

p. 264

Printed: see Exercise 2.3.9
Fixed: see Exercise 2.3.11
Reported by Zhou Changling, 02-Sep-09.

p. 264

Printed: more than 31 years and 1.4 million centuries
Fixed: more than 34 years and 5.8 billion centuries
Reported by Zhou Changling, 02-Sep-09.

p. 279, Exercise 2.3.8

Printed: replace + with *
Fixed: replace + with * and return 0 with return 1
Reported by Marshall Farrier, 21-May-10.

p. 280, Exercise 2.3.13

Printed: log2 N
Fixed: 2 log2 N + 1
Reported by Marshall Farrier, 23-May-10.

p. 308, Exercise 2.4.1

Printed: refers to Exercises 1.4.13, 1.4.25, and 1.4.33
Fixed: should refer to Exercises 1.4.14, 1.4.26, and 1.4.37
Reported by Zhou Changling, 11-Sep-09.

p. 308, Exercise 2.4.5

Printed: recursive show() method
Fixed: recursive flow() method
Reported by Michael Leuschel, 06-Dec-10.



CHAPTER 3

p. 335, Program 3.1.6

Printed: // Compute blend of c and d, weighted by x
Fixed: // Compute blend of c and d, weighted by alpha
Reported by Michael Leuschel, 12-Feb-11.

p. 342, Program 3.1.8

Printed: if ((codon.equals(stop)) && beg != -1)
Fixed: if ((codon.equals(stop)) && beg != -1 && beg + 3 < i)
Reported by Joshua Hug, 24-Oct-11.

p. 348

Printed: See the Context section at the end of this book for some details about this language.
Fixed: Remove reference to HTML in Context.
Reported by Michael Leuschel, 12-Feb-11.


p. 349

Printed: print one line per column, with commas separating row entries
Fixed: print one line per row, with commas separating column entries
Reported by Zhou Changling, 27-Sep-09.

p. 350

Printed: java Split DJIA 3
Fixed: java Split DJIA 4
Reported by Michael Leuschel, 12-Feb-11.

p. 391

Printed: Complex (Program 3.2.2)
Fixed: Complex (Program 3.2.6)
Reported by Richard Bliss, 10-May-10.

p. 397

Printed: int t = 512 - mand(z0, 512);
Fixed: int t = 255 - mand(z0, 255);
Reported by Jørgen Villadsen, 06-Apr-10.

p. 411

Printed: a[i]. change(-2);
Fixed: a[i]. increaseCharge(-2);
Reported by Abhishek Rawat, 05-Apr-10.

p. 421

Printed: Program 3.2.5 (twice)
Fixed: Program 3.2.6 (twice)
Reported by Richard Bliss, 10-May-10.

p. 460

Printed: Vector delta = a.r.minus(b.r)
Fixed: Vector delta = b.r.minus(a.r)
Reported by Kevin Wayne, 10-Nov-09.



CHAPTER 4

p. 482

Printed: NBody
Fixed: Universe
Reported by Michael Leuschel, 04-Mar-11.

p. 513

Printed: T(1) = 1
Fixed: T(1) = 0
Reported by Kenneth Sloan, 04-Nov-10.

p. 529, mergesort trace

Printed: the
Fixed: his
Reported by Michael Leuschel, 04-Mar-11.

p. 531

Printed: StdStats.select()
Fixed: StdStats.median()
Reported by Michael Leuschel, 04-Mar-11.

p. 607, Exercise 4.3.49

Printed: no base case in recursive reverse()
Fixed: if (first == null || first.next == null) return first;
Reported by Keith Vertanen, 06-Dec-10.

p. 646, Exercise 4.4.52

Printed: void get(int i)
Fixed: char get(int i)
Reported by Richard Bliss, 10-May-10.