Algorithms in a Nutshell

Algorithms in a Nutshell — George T. Heineman, Gary Pollice & Stanley Selkow, O’Reilly 2016 (2nd ed.), ISBN 978-1-491-94892-7

This fairly slim book covers the basics of algorithmics and benchmarking, and also provides pseudocode and implementations (in C/C++, Java, and Python) for nearly 40 important algorithms. The major drawback is obvious when you consider that this mass of information was crammed into a mere 380 small-format pages: explanations can be abbreviated to the point that understanding suffers, and much implementation code was omitted from the print edition to save space. You’ll need to download the full repository from GitHub to get actual working code.

So while your first choice for a practical guide to algorithms should still be Sedgewick’s classic, the unique strength of Heineman et al. is the sheer number of described algorithms, many of which are poorly covered elsewhere. Aside from the expected standard entries on sorting & searching and graphs, you will find an entire chapter on game AI including turn evaluation (alpha-beta, minimax) and path searches (A*, breadth-first, depth-first), another chapter on network flow algorithms, and two chapters on computational geometry. That field was much enhanced in the 2nd ed. and now comprises convex hulls, line-segment intersections, line-sweep, and Voronoi diagrams, as well as spatial tree structures.

Some other unusual choices include Bloom filters, approximation and probabilistic algorithms, and a parallel quicksort. Most algorithms are helpfully illustrated by graphs on their empirical behavior and runtime performance. All told Algorithms in a Nutshell is a surprisingly well-stocked treasure trove that makes an excellent companion to a more basic introductory book.

(See Developer Books for my complete review archive.)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.