Errors and comments

Page 108 and 110. Shouldn’t the right hand node under 50 be something larger than 50 rather than 35? Later on page 110 it is 55 and not 35.

Grammer on pg 213
“It’ i’s very easy to get the weight of an edge;”

Thank you for the heads up - much appreciated! We will fix this in the book’s next release.

There is a typo on page 45 in the .pdf and 67 in the epub version. At the bottom of the page, in the last sentence of the next to the last paragraph, is printed, “you’ll bad glad to know…”. I’m betting you meant “you’ll be glad…”

Incomplete sentence on pages 48/73 (pdf/epub) in the “Less is more” section, 2nd paragraph: “However, since you can write an initializer that just sets the underlying private storage.”

On page 101 of the pdf the first sentence of the “Where to go from here?” section reads: “The BST is a powerful data structure that can delivers great performance”.

Either it can deliver or it delivers, not both. :wink:

Thank you for catching these. They will be fixed soon.

So, I think the AVL tree right-left rotation text and image are both in error on. page 119 of the hardcopy (it’s still in error in the latest pdf). The diagram caption in the middle says "Left rotation on 37’, which should be ‘right rotation on 37’, since it’s a right-left rotation. Also, the diagram is confusing - it shows 37 as a left child of 36 after the first pivot, which is incorrect, it should be the right child.

On the next page (120), where it shows a similar diagram for left-right rotations, the image caption is correct (it says 'left rotate of 10), but the image still seems wrong - it shows 10 as a right child of 15 after the initial left rotate, whereas I believe 10 should now be the left child of 15.

If I got my lefts and rights mixed up here explaining it, forgive me, my head is spinning right now, but I’m pretty sure I’ve got it straight now :). In any case, I believe if you look at page 119-120, you can quickly confirm/deny if my correction is itself correct :).

Thanks for a great book.

As of yesterday, the latest release should rectify that issue! Sorry for the confusion.

Thanks, Kelvin. Once again, awesome book.

Binary Tree Solutions (Chapter 13)
return 1 + max(height(of: tree.leftChild), height(of: tree.rightChild))
It should be:
return 1 + max(height(of: node.leftChild), height(of: node.rightChild))

Btw, great book so far! Just for curious, can you give a real world example where a linked list makes sense to use?

Errata
On page 341:
// 3

if let min = min, tree.value <= min { return false }
else if let max = max, tree.value > max { return false }

But as stated in page 117:
• The value of a left child must be less than the value of its parent.
Consequently, the value of a right child must be greater than or equal to the value of its parent.

So it should be: tree.value < min and tree.value >= max, cause the leftChild should always be less that parent, and the rightChild could also be equal.

Hi @ivangodfather, that’s a great question! One example I could think of is a web browser that has a history feature. When you check the history you can go back, you are fetching the previous node.

Best,
Gina

@ivangodfather Thank you for catching these - much appreciated. We will definitely fix them in the next version of the book.