Errata: October 16, 2018
Unless otherwise noted, all corrections have been made to the pbook; corrections to the mobile and livebook versions are pending.
Thank you for purchasing Grokking Algorithms. Please post any errors, other than those listed below, in the book's Author Online Forum. We'll update this list as necessary. Thank you!


Page 7

In the third to the last line of the sidebar, "Logarithms", the number 3 should be 4:
So for a list of 8 numbers, you would have to check 4 numbers at most.

Page 8

The mid statement in the next to the last snippet is missing an / character.

mid = (low + high) // 2

Page 9

The mid statement in the first snippet is missing /2.

mid = (low + high) / 2

Page 11

The number of milliseconds in the second line is incorrect. It should be 30:
"30 ms!"

Page 16

The values listed under 0(n1) are incorrect:
8.6x10505 years should be 2.7x10498 years
5.4x102638 years should be 1.7x102631 years

Page 35

The chapter reference in the first para following the sidebar should be chapter 4.
Its coming up in chapter 4!

Page 41

The 0 in the third line in the second code snippet should be 1:

if i <= 1:

Page 43

The second def statement in the second code snippet should be alinged with the first def statement:

def greet2(name):
    print "how are you, " + name + "?"

def bye():
    print "ok bye!"

Page 56

The grid is 14 X 8; it should be 21 x 8.

Page 63

The second sequence iin the partition array is incorrect. The correct sequence is 1, 3, 5, 2, 4.

Page 70

Add the following to the end of the first paragraph:
You can get the best case consistently, as long as you always choose a random element as the pivot. Read on to find out why.

Page 82

the print statement is missing the letter t:

print "kick them out!"

Page 94

The number .07 in the fifth bullet should be 0.7:
Once your load factor is greater than 0.7, it's time to resize your hash table.

Page 122

The last sentence before the "Trading for a piano" section should read:
Dijkstra's algorithm only works on graphs with no cycles, or on graphs with a positive weight cycle.

Page 132

In the third snippet the numbers 2 and 6 should be transposed:
>>> print graph["start"]["a"]
6
>>> print graph["start"]["b"]
2

Page 147

In the first sentence following 2., the word stations should be 2^n subsets:
The problem is, it takes a long time to calculate every possible subset of 2^n subsets.

Page 149

The annotaton for the second code snippet should point to the first line of code, not the second.

Page 151

The last two lines of code in the while snippet at the bottom of the page should align with the for statement.

Page 152

The first line of the heading for the second column in the table just before the Exercises section should be 0(2^n), not 0(n!).

Page 173

The currency value in the bottom-left cell of the first grid should be $2000, not $3500.

Page 182

The value in the bottom-left cell in the first grid (H row) should be 1, not 0.
The value in the bottom-left cell in the second grid (H row) should be 1, not 0.

Page 231

The answer to 8.4 is No.