## REVIEW - Learning Algorithms - A Programmer's Guide to Writing Better Code

Title:

Learning Algorithms - A Programmer's Guide to Writing Better Code

Author:

George Heineman

ISBN:

9781492091066

Publisher:

O’Reilly Media (2021)

Pages:

350

Reviewer:

Simon Sebright

Reviewed:

January 2022

Rating:

★★★★☆

Recommended

This book is aimed at programmers who want to get to grips with the basics of algorithms useful in computing – to find out what they do, how they work, how to choose the most appropriate one. It is not intended to be a deeply theoretical mathematical work, rather a practical guide, showing how a range of standard algorithms are designed and can be programmed, in this case using Python code examples.

The first chapter introduces us to the big O notation, starting with some simple algorithms, seeing what it means to be O(1), O(N), O(NlogN), etc. These are shown with some code examples and comprehensive performance measurements over a range of input data sizes. From this, we learn what to look for in an algorithm’s code, to be able to determine its performance characteristics with respect the input data size.

Then the book proceeds chapter-by-chapter to introduce new data structures and typical algorithms which these are used with. I found that the book could have been called Learning Algorithms and their Data Structures or similar, because the design of the data structures goes a long way to the actual implementation of the algorithms. Typical code libraries might provide these structures and algorithms together, but the book uses its own code mostly to show how the structures are created and how the algorithms work. One exception in the last chapter is the import of a Python graph library to model graphs, but the algorithms are shown as actual code examples.

Example topics include sorting, searching, trees, queueing (FIFO, first in/first out, priority queues), stacks (LIFO, last in/first out) and graphs.

Each chapter has a set of ‘challenging exercises’ at the end. I didn’t try any of these, but they looked interesting if I had wanted to get my hands dirty.

I found the explanations and code samples easy to follow, even though I have never programmed in Python. I must admit I did not try download the accompanying code. Mostly they are not more than half a page long and clearly explained afterwards with a line-by-line description of what is going on.

I gave the book a recommended review, as I think for the target audience it’s great start to this topic. It certainly is not trivial, as I realized when I wasn’t able to concentrate that well, I had to re-read. On the other hand, the material is not too complex to be overwhelming and topics are gradually introduced and go into the complexity bit-by-bit.

Whilst most people will not be inventing new fancy algorithms every day, and will hopefully using library versions rather than writing their own versions of functions, I think a good basic understanding of these is important, in order to identify the right approach given your given requirements, input data sizes, performance limitations, etc.