If you have ever read Donald Knuth's The Art of Computer Programming and thought, "Surely it can be easier than that!", Algorithms in a Nutshell is for you. The authors provide a handbook of the most commonly used algorithms for a large variety of problems. There are not many areas untouched by the algorithms and wisdom shared by the authors in this book.
In writing the book, the authors were guided by several principles which they state in the preface. These do more than frame the book, they make it one of the best treatments on a very difficult topic to come out in recent years. The principles in practice are:
- Use real code, not pseudocode
- Separate the algorithm from the problem being solved
- Introduce just enough mathematics
- Support mathematical analysis empirically
The authors presume no knowledge of algorithms - not even as a concept - and begin by defining the problem they are to solve. The authors further presume little understanding of mathematics and help the reader understand them as they go. The book also contains copious diagrammes which illustrate how the algorithms function.
Algorithms from the Ground Up
Of the three sections of the book, the first justifies the topic and lays the mathematical basis for the rest of the book. The matter of dealing with problems based on patterns is also dealt with.
In the second section of the book, each chapter provides a discussion of several related algorithms. These discussions are succinct but not terse and are heavily illustrated. The authors tend to get the right balance to make the book very helpful without being either wordy or cryptic. Topics covered include sorting, searching, graphing, path finding, network flow, and computational geometry.
When All Else Fails
That wide swath of topics are then complemented by the lead chapter of section three, "When All Else Fails." The book is then rounded out with an epilogue containing several principles for modifying the algorithms presented so to best solve one's problems:
- Know your data
- Decompose the problem into smaller problems
- Choose the right data structure
- Add storage to increase performance
- If no solution is evident, construct a search
- If no solution is evident, reduce your problem to another problem that has a solution
- Writing algorithms is hard - testing algrotithms is harder
Keeping What You Once Had
It must be noted that much of this book is covered in some way by
university-level computing degrees. Nonetheless, one tends to forget
the principles and the algorithms themselves. One develops one's
handful of favourites. This book helps one to keep playing with a