The Moral of the Story

The previous story really happened. Algorithms do matter. You might ask whether the tree-balancing algorithm was the optimal solution for the problem. That's a great question, and one that we'll answer by asking another question: does it really matter? Finding the right algorithm is like finding the right solution to any problem. Instead of finding the perfect solution, the algorithm just has to work well enough. You must balance the cost of the solution against the value it adds. It's quite possible that Gary's implementation could be improved, either by optimizing his implementation or by using a different algorithm. However, the performance of the memory leak detection software was more than acceptable for the intended use, and any additional improvements would have been unproductive overhead.

The ability to choose an acceptable algorithm for your needs is a critical skill that any good software developer should have. You don't necessarily have to be able to perform detailed mathematical analysis on the algorithm, but you must be able to understand someone else's analysis. You don't have to invent new algorithms, but you do need to understand which algorithms fit the problem at hand. This book will help you develop these capabilities. When you have them, you've added another tool to your software development toolkit.

Get Algorithms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.