Errata, Chapter 1


p. 38

Printed: 10^6 not 100000 but 12
Fixed: 10^6 not 1000000 but 12
Reported by Swami Iyer, 19-Oct-07.

p. 47

Printed: if (x > y) { int t = x; y = x; x = t; }
Fixed: if (x > y) { int t = y; y = x; x = t; }
Reported by Alfred Miller, 16-Feb-08.

p. 72, figure

Printed: 4th Hello 4th Hello 4th Hello
Fixed: 4th Hello 5th Hello 6th Hello
Reported by Sailesh Dhungana, 21-Oct-07.

p. 73, figure

Printed: EightHellos, DivisorsPattern, Newton, Factor
Fixed: TenHellos,   DivisorPattern,  Sqrt,   Factors
Reported by Swami Iyer, 3-Oct-07.

p. 77, Exercise 1.3.2

Printed: Exercise 1.3.3
Fixed: Exercise 1.2.3
Reported by William C. Nguyen, 26-Sep-07.

p. 79, Exercise 1.3.17

Printed: 1 - f(t) / f'(t)
Fixed: t - f(t) / f'(t)
Reported by Susanne Sherba, 30-Nov-07.

p. 91

Printed: "2", "3", "4", "5", "6", "7", "8", "9", "10"  "Jack",  Queen", "King", "Ace"
Fixed: "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"
Reported by Michelle Lu and Jacob Hiller, 30-Sep-07.

p. 94, Program 1.4.1

Printed: perm[j] = t;
Fixed: perm[i] = t;
Reported by Thomas Kneeland, 28-Sep-07.

p. 95

Printed: the values of N and M are 16 and 5
Fixed: the values of N and M are 16 and 6
Reported by Michelle Lu, 30-Sep-07.

p. 100, Program 1.4.3

Printed: for (int i = 2; i < N; i++)
Fixed: for (int i = 2; i <=N; i++)
Reported by Hank Song, 19-Feb-08.

p. 100

Printed: % java PrimeSieve 17
Fixed: % java PrimeSieve 25
Reported by Swami Iyer, 27-Oct-07.

p. 104 and p. 106 figures

Printed: for (int j = 0; j < N; i++)
Fixed: for (int j = 0; j < N; j++)
Reported by Thomas Kneeland, 28-Sep-07.

p. 109

Printed:
if      (r < 0.25 && !a[x+1][y]) x++;
else if (r < 0.50 && !a[x-1][y]) x--;
else if (r < 0.75 && !a[x][y+1]) y++;
else if (r < 1.00 && !a[x][y-1]) y--;

Fixed: if      (r < 0.25) { if (!a[x+1][y]) x++; }
else if (r < 0.50) { if (!a[x-1][y]) x--; }
else if (r < 0.75) { if (!a[x][y+1]) y++; }
else if (r < 1.00) { if (!a[x][y-1]) y--; }
Reported by Greg Humphreys, 27-Jul-07.

p. 113, Exercise 1.4.7

Printed: System.out.println(i)
Fixed: System.out.println(a[i])
Reported by Matthias Makowsky, 19-Jun-08.

p. 116, Exercise 1.4.20

Printed: The value dist[i]
Fixed: The value dist[k]
Reported by Swami Iyer, 29-Oct-07.

p. 149

Printed: 4410000/44100
Fixed: 441000/44100
Reported by Andrea Brewer, 01-Oct-07.

p. 149

Printed: void double[] read(String file)
Fixed:      double[] read(String file)
Reported by Sailesh Dhungana, 22-Oct-07.

p. 164

Printed: multiply outDegree[i][j] by .90 / degree[i]
Fixed: multiply count[i][j] by .90 / outDegree[i]
Reported by Swami Iyer, 18-Oct-07.

p. 165, variable description box

Printed: outDegree[j]
Fixed: outDegree[i]
Reported by Swami Iyer, 18-Oct-07.

p. 165

Printed: StdOut.println(N + " " N)
Fixed: StdOut.println(N + " " + N)
Reported by Kevin Wayne, 18-Jun-07.

p. 171

Printed: (.02 * .02) + (.02 + .32) + (.32 * .02) + (.32 * .02) + (.32 * .47) = .17
Fixed: (.02 * .02) + (.02 + .38) + (.38 * .02) + (.38 * .02) + (.20 * .47) = .12
Reported by Swami Iyer, 16-Nov-07.