Best Algorithms Books (Part 2)

He had read much, if one considers his long life; but his contemplation was much more than his reading. He was wont to say that if he had read as much as other men he should have known no more than other men (italics mine)
~ Isaac Asimov (my late Dad was a Sci Fi buff, and Asimov was one of his fav authors)
🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸
Today is September 11, and as Americans, what better way to put our patriotism into practice than by 🇺🇸 Helping those affected by Hurricane Irma (Florida) and 🇺🇸 continue helping those affected by Hurricane Harvey (Texas)!
🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸🇺🇸

A lot of careers are based on a perceived need and people find ways to solve critical problemsmedical careers, for examplewhile while other careers like computer science are chosen because of the kind of mind structure that you develop as a child.
~ Donald Knuth
 

I refuse to accept the view that mankind is so tragically bound to the starless midnight of racism and war that the bright daybreak of peace and brotherhood can never become a reality… I believe that unarmed truth and unconditional love will have the final word.
~ Martin Luther King, Jr.

First, thank you all so much for the warm reception that you’ve given to the first installment in this series of reviews of algorithms books, by way of an earlier essay—post really, though I’ve become enamored of calling them essays, after Paul Graham’s trendy essays—which was entitled Best Algorithms Books (Part 1) 🎉

In this essay, which has that trailing “Part 2″ in its name, I’m making good on my promise—one that I made toward the end of the previous installment in this seriesof a second installment. In a tangential sort of way, the numbering I’ve used here for the five books (reflecting their relative ranking), and for which we’ll soon be doing a deep dive, is inspired by legendary computer scientist Donald Knuth’s Potrzebie system of weights and measures 😆

Look, I might be recalcitrant at times, when it comes to digressing in my essays, but I’m not incorrigible, at least I hope not lol; I trust that my occasional obstinacy in digressing does not come across as bordering on impudence. Rest assured that, this time around anywayunlike the previous installment where digressions were center squaredigressions will appear only after the essay proper 😉

So here we go, starting with a ranking of the second half of the top ten algorithms books of all time—the top five, of course, were covered in the prior essay, entitled Best Algorithms Books (Part 1). Here, then, are the next five stellar books on the enduringly evergreen subject of algorithms 🌳

6.  Algorithm Design and Applications (Wiley) by Michael Goodrich and Roberto 🌿
7.  Algorithmics: The Spirit of Computing (Springer) by David Harel and Yishai Feldman 🍀
8.  Pearls of Functional Algorithm Design (Cambridge University Press) by Richard Bird 🌵
9.  How to Think About Algorithms (Cambridge University Press) by Jeff Edmonds 🌴
10. Algorithms Unplugged (Springer) by Berthold Vöcking et al 🌲

Since writing the prior essay on algorithms, I’m even more convinced that there is no subject in computer science—at least from a practitioner’s perspective—more central to its vitality than that of algorithms. In a nod to an observation I had made elsewhere, I’m eagerly thinking here to how my fascination with algorithms, and in particular their rich applicability to distributed programming, would have us travel back through the mists of time; OK, just kidding, so I’m not that old 🙉

If you squint hard at the pic above—I surreptitiously dragged it in since we got to digressing, even if ever so briefly, about traveling back through the mists of time—you’ll note the shadowy presence of your blog writer in an act of taking a virtuously recursive pic 🎃  Oh, and speaking of art, we should sometime chat about the time when my childhood buddy (who also happens to be my nephew) and I took an awesome tour of the mind-blowing Solomon R. Guggenheim Museum in New York City, nearly two decades ago🎢
🔦  Mild alert regarding strongly opinionated and iconoclastic views ahead—though I hasten to assure you that it’s all polite discourse throughout—and where I, gasp, bypass CLRS yet again in my take on  the pursuit of algorithmic excellence 🔦

So, following on the heels of the first installment—Best Algorithms Books (Part 1)—in this series, I  now present an equally opinionated look at another set of outstanding books on algorithms, those in the list above. I will, though, be casting a glance back at my constantly-in-progress, and happily interminable, trek through the fascinating land of algorithms. As I do so, I’ll be taking an opinionated look at the following books, in turn. With that, I present to you the second set of books that have proved incredibly helpful to me in grokking algorithms ⚽ ⚾ 🏀 🏈 🎾 🏊 🏃 🏆

6.  Algorithm Design and Applications (Wiley) by Michael T. Goodrich and Roberto Tamassia 🌿

I came upon this remarkable book by sheer accident, while doing an online search for background material in connection with the forerunner of this book—Data Structures and Algorithms in Java 6th Edition (Wiley), one of whose three authors (Roberto Tamassia) also happens to be the coauthor of this fine book: Algorithm Design and Applications (Wiley) by Michael T. Goodrich and Roberto Tamassia 🏆

Capturing the essence of Algorithm Design and Applications is made difficult by the fact that there is so much that is so good about it. But let’s try. So the best analogy I can draw is by way of saying that if you took Data Structures and Algorithms in Java 6th Edition—a book that has an unwavering, laser-sharp focus on sticking to just the basic facts (Pink Floyd, anyone?)—and had it do a deep dive into the ocean that lurks beneath the surface to truly revel in the wonders of the teeming depths of uncompromising rigor, then you would get this amazing book, Algorithm Design and Applications.

Relax
I’ll need some information first
Just the basic facts

~ Roger Waters (lyrics from the Pink Floyd song Comfortably Numb)

If you’re looking to read only one algorithms book (to pick from this second set of books), look no farther than this extraordinarily well done volume. In its pages, you can unhurried stroll through the vistas of algorithm design, with a resoundingly emphatic nod to, and emphasis on design. If you’re wanting to get to know the nuts and bolts of algorithms in an intelligent and pragmatic way—you know, roll up our sleeves and learn sufficiently and solidly enough to get the job done way?—then this book’s precursor of sorts (Data Structures and Algorithms in Java 6th Edition) would be a great choice.
However, should you wish to go deeper, much deeper, and with decidedly greater nuance and sophistication, then this book—Algorithm Design and Applications—may well be the book for you. It’s seemingly simple presentation style belies incredible depth, which simply couldn’t have just happened by accident; that depth is hard to convey. You really do have to get your hands on this gem to see for yourself its sparkling offerings on shedding a flood of light to reveal the vast vistas that inhere in the land of algorithms. So kudos to the authors—Professor Goodrich (UC Irvine) and Professor Tamassia (Brown University)—for distilling their design wisdom into the pages of this gem.
I say: High commendations from a fellow craftsman who plies the serene—and at times turbulently creative—seas of computer science in the unrelenting quest to elevate his programming skills to the next level, in his own wayward ways (oxymoron alert) 🏄 So awesome is Algorithm Design and Applications that I was compelled to look for anything else published by its authors…
And guess what? Yep, I did find, and buy, yet another fine book by the same authors, yay 🎓 That one is entitled Handbook of Graph Drawing and Visualization: Discrete Mathematics and Its Applications by Roberto Tamassia and it’s looking really good. Now if I can only make time to read it in any depth; till then, I’ll try to save it from languishing in my library-inbox of sorts 📬
My formula there, in selecting books for study, is blindingly simple in that all I do is remind myself: Akram, you found something good, now you stick to it! That’s it 🙋 That’s why I have a handful of authors whose work I like so much that I’ll simply buy and read anything they write. Period. Should you be interested in their work, I invite you to check out an essay I wrote a while ago, called Top Thought Leaders to Follow. In there, you’ll meet not only familiar luminaries of our field—Martin Fowler and Robert “Uncle Bob” Martin, just to name two—but also other thought leaders whose names may be less familiar: Allow me to introduce to you, for example, Elizabeth Grace Saunders, Salman Khan, and Cal Newport. Their trailblazing work is not to be missed 🙇
So I was saying… Having discovered—in recent years, actually—in Algorithm Design and Applications a treasure trove of design wizardry, I’m still hacking away at the nuggets that I keep uncovering in its glorious pages, as and when I can make time. Ah time, most precious of commodities that thou art, if only we could find ways to manage thee, and manage thee well ⏳⏰⌛

Algorithm Design and Applications is replete with tasteful illustrations, which are neither overdone nor cheesy. It’s got tons of crystal-clear presentations of theorems, along with accompanying proofs that are, IMHO, marvels of elegance and beauty. Truth be told, had I given more thought to it earlier—given the premium that I, as a software craftsman, place on pursuing the nexus between beautiful code and beautiful proseAlgorithm Design and Applications may well have landed in the top spot of my best algorithms books of all time 💯

While a paperback edition is not available at this time, I can only recommend plunking down the extra money to get a hardcover copy of Algorithm Design and Applications. Trust me, I don’t have a cent to make off of the sales of this book 💰 💲 💵 😱 But as a writer who’s committed to serving his readers, I feel compelled to share with you the fruits of my research labors: Share with you all that I’ve found—and continue to find—about what works, and what doesn’t, what’s truly useful, and what isn’t 💪

Though I have the ebook version of this book as well, I find it far more effective to study the physical book—highlighter in hand, plus a stash of tape flags with which to mark up the pages close at hand, too. Surely there is a method to the madness, something like a visual variant of coding and cataloging, inspired by the venerable Dewey Decimal system that permeates our libraries, or at least it used to, last time I checked, many moons ago, as a graduate student at Texas A&M University 🌛

Speaking of a method to the madness, I may well be in good company because I find myself reminded of a marvelous passage that I savored a few years ago, in the wise and scintillating pages of the book The Distraction Addiction: Getting the Information You Need and the Communication You Want, Without Enraging Your Family, Annoying Your Colleagues, and Destroying Your Soul

So I was saying… No doubt we’ve all grown accustomed—in any given technical book that’s worth its salt—to the exercises which routinely appear at the end of any given chapter. Well, be prepared to be wowed by what Algorithm Design and Applications does in this department: While this book does have all that, and then some, what truly sets it apart is the way those end-of-chapter exercises are thematically organized. Here’s the deal: To guide the reader in maximizing her reading experience, the authors have arranged the exercises in thematic chunks, labeled Reinforcement, Creativity, and Applications, respectively.

The book is replete with thematic chunks—Reinforcement, Creativity, and Applications—that will get you going in short order, organized under the headings:

  • Reinforcement
  • Creativity
  • Applications

Only one other algorithms book comes to mind that comes somewhat close to this one in the department of high caliber end-of-chapter exercises: Algorithm Design (Pearson) by Jon Kleinberg and Éva Tardos.

Oh, and as if that weren’t enough, the authors of Algorithm Design and Applications round out each chapter with a cogent set of notes that include tips on how best to pursue a given topic in even greater depth—all I can say is, “Guys, can you please have your marketing department do a better job of making this gem of a beautiful book more widely known?!”

So here’s a question: Why does CLRS get all the limelight when most all of us in the programming community are practitioners, and not researchers. And yes, most of us aren’t into bondage-and-discipline languages either, as hilariously defined in the The New Hacker’s Dictionary, Third Edition. We prefer our algorithmic resources to be written for normal people; I hasten to point out that The MIT Press has other books which are consistently at the right level of difficulty and comprehension and are, frankly, plain awesome!

And then we had this aberration in the form of CLRS, alas. Cryptic notations that I have neither the time nor the inclination to master in order to wade through the morass of equally enigmatic coverage. I concede that CLRS is peerless when it comes to the matter of a single resource for finding references to the sprawling literature on the genteel subject of algorithms—well, it used to be a courtly subject until folks started putting the substantial algorithmic literature to their remarkable advantage and in the process propelling their businesses into the upper stratosphere of profitability 🚀

As a sucker for adorning—some might say embellishing, though I’ll politely beg to differ—essays with topical quotes, images, and excerpts to create a pleasurable reading experience, I was pleased by the way each chapter in Algorithm Design and Applications starts out with an endearing photo each that is refreshingly black-and-white and nicely complements the theme of any given chapter. For example, the theme of Chapter 16—Network Flow and Matching—is pleasingly accentuated by an endearing photo of Yellowstone Falls (1941) by Ansel Adams 🐑 🐢 🐝 🐞 🐌

I love this book. Don’t miss it. It will help you elevate your programming skills, plus—and more importantly so, your design skills—to the next level. Again, the uncompromising commitment to help the reader become the best designer she can be is evident and writ large throughout the pages of Algorithm Design and Applications. In the process of reading it, learning ceases to be a chore and instead becomes true pleasure. Yes, it is one of those rare books 🏁

Before moving on to the next algorithms book in this opinionated essay, I confess that I would have—if only I could turn back the hands of time—put this book in the pantheon of my top five algorithms books, which you hopefully enjoyed finding more about in the previous installment of this series of deep-dive reviews into the algorithms genre. So I ruefully ask of you to please keep this in mind as you continue to revisit this series of deep-dive reviews.

7.  Algorithmics: The Spirit of Computing 3rd Edition (Springer) by David Harel and Yishai Feldman 🍀

Here’s a confession that I feel compelled to make: I’ve never been terribly impressed by the publishing quality of the books published by Springer—with some notable exceptions—and while this book is an improvement, it sure could have used a better format. Look, every book simply cannot hope to have a premier quality format like that of Algorithms 4th Edition (Addison-Wesley) by Robert Sedgewick and Kevin Wayne, which, as many of you will recall, got the top spot in Best Algorithms Books (Part 1).

There should IMHO, however, be a modicum of quality to enhance the reading experience ☕ And here I bring closure to the thought on a happy note  Springer has redeemed itself by publishing another book of excellent quality, reaffirming my faith in what their publication quality can be. Plus you don’t have to go far to get the scoop on that book—Algorithms Unplugged (Springer) by Berthold Vöcking et al—since it happens to be in the tenth spot in our list of the top 10 algorithms books (Should I do a third installment of this series of essays in the future, then we would naturally get the top 15 algorithms books; that may or may not happen, depending on reader interest, which BTW has been tremendous so far woohoo). Anyhow, we’ll get to Algorithms Unplugged in short order. Stay tuned 🎬 🍎 🎯

Meanwhile, we return to the seventh book in our list. So the second book on our list has content that is nearly unmatched in the length and breadth of the computer science and programming literature. Ladies and gentlemen, rest assured that the stellar content of this book—and allow me to introduce Algorithmics: The Spirit of Computing 3rd Edition (Springer) by David Harel and Yishai Feldman—more than makes up for the, um, less than stellar book format, which is not too shabby either. By the way, there are no problems whatsoever with the ebook, of which I also own a copy; ah yes, the digital media remains unencumbered by the frailties that sometimes attend the physical media ⛳

The reason Algorithmics got such a high spot on the list is its stellar content, the likes of which I have yet to see anywhere else! Dr Stan Scott, with Queen’s University (Belfast, Ireland), probably put it the best when he noted in The Times Higher Education Supplement how this book

Through the use of tantalizing questions and aptly chosen and often amusing examples, the author transmits to the reader the excitement and intellectual satisfaction of computer science research. Without the use of formal mathematics and without any sacrifice of intellectual integrity, he conveys to the general reader the profound principles on which computer science is founded and which hitherto were only accessible in abstruse and esoteric textbooks and papers. 
This is scientific writing at its best.

Oh goodness, it sure is scientific writing at its best: The charter of this blog—to host essays at the intersection of culture, software, technology, and science—is proud to share a book that is the culmination, and then some, of the ineffable confluence of software, technology, and science 💻 📦 📡

You should know upfront that Algorithmics has a story to tell. This ain’t no cobweb-laced, put-you-to-sleep boat anchor that would sink you ⚓ Think of it as an adventure through the guts of computer science, with a strong emphasis, of course, on the concepts, ideas, methods and results that are fundamental to computer science. Also know that you won’t get bogged down with formalisms, though they (i.e. formalisms) do have a rightful place; take this from someone smitten by the lambda calculus 😎

The subtitle—The Spirit of Computing—of Algorithmics is spot on because once you make your way through the pages of this remarkable book, you won’t look at computers in quite the same way. You’ll come away with kinship for the true spirit of computers: In other words, exactly what it is that make them tick (hint, hint: their algorithms) ⏰⌚

For those unfamiliar with the name David Harel, suffice it to say that he is a hugely influential individual in the firmament of theoretical computer science, being one of the leading researchers. He also happens to be the chairman of the Applied Mathematics and Computer Science Department at the renowned Weizmann Institute of Science 🏰

Think of Algorithmics as an endearing tour of theoretical computer science at the proverbial elevation of 50,000 feet, or is it 100,000 feet, or, heavens be praised, 10,000 feet, though that seems a bit too close to the ground for comfort? 🚁 Anyhow, I think you got the idea, right? 😉

Since we’re talking about having a head for numbers, you might as well know that I’m incorrigibly bad at arithmetic, though pretty darned good at the logical layering and analysis—and synthesis, to be sure—which I use on a daily basis while going about my software design and development activities. Go figure!

The writing style of Algorithmics is truly exceptional; we have in Harel a master who is surveying his area of expertise with a magisterial command that reflects both his perspicacity and perspicuity. And believe it or not, it’s written in a clear style that makes it suitable even for the layman—and laywoman, to be sure! I hastened to add the latter since I support egalitarian feminism, which you may have gathered from the quote atop this essay 👰

You’ve Come a Long Way, Baby (Or Have You?)

~ Ruth Rosen

The Rosen quote above, by the way, was aimed squarely at accentuating and amplifying the prior quote—in the context in which it had appeared, juxtaposed as it was with the following quote, atop this essay—where we heard a luminary of our field reminiscing about how

This was the first graph problem I ever posed myself and solved. The amazing thing was that I didn’t publish it. It was not amazing at the time. At the time, algorithms were hardly considered a scientific topic (bold is mine) 

~ Edsger W. Dijkstra (as quoted by Dennis Shasha and Cathy Lazere in Out of their Minds: The Lives and Discoveries of 15 Great Computer Scientists (Copernicus))

To dig deeper still, I’d recommend a math textbook or two to accompany your study of Algorithmics—in and of itself, though, it’s plenty good as a superb starting point 🚀

And listen, to those who have objected to Algorithmics, saying that they returned this masterpiece because they demurred to the Biblical quotes that are tastefully sprinkled across its pages, all I have to say is this: Guys and gals, let’s all of us please grow up 🌍 🌎 🌏 We’re one global family, which is a point that brings me to the fourth of the four quotes that I had selected, after much deliberation, to adorn the outset of this essay:

I refuse to accept the view that mankind is so tragically bound to the starless midnight of racism and war that the bright daybreak of peace and brotherhood can never become a reality… I believe that unarmed truth and unconditional love will have the final word. 

~ Martin Luther King, Jr.

If you come to Algorithmics with the following sort of idea, I can nearly guarantee that you won’t be disappointed. Period.

Computer Science is no more about computers than astronomy is about telescopes.

Next up, we’ll segue into an algorithmic twist on the beguiling world of functional programming, an area which—as long-time readers of my blog will attest to—was, and remains, near and dear to my heart 💕

8. Pearls of Functional Algorithm Design (Cambridge University Press) by Richard Bird 🌵

Two things to keep in mind as you read what I have to say here about Pearls of Functional Algorithm Design (Cambridge University Press) by Richard Bird. As a writer who’s committed to serving his readers, I want to get my biases in front of you to let you make better and more informed choices as you go about your journeys of learning. In no particular order, please know that

    • I am intrigued by the promise of blending object-orientation (OOP) with functional programming (FP), as I’ve tried to articulate elsewhere 🌹
    • I firmly believe that a programming language like Scala is well-positioned to serve as a bridge between the object-orientation of Java and the functional programming languages, as I’ve tried to demonstrate elsewhere 🚠
    • I am in full agreement with Eric Raymond’s assessment that the Lisp programming language—think Clojure, the Lisp-for-the-JVM programming language—is worth learning for the profound enlightenment experience you will have when you finally get it, as I’ve tried to explain elsewhere 💡

My biases in this area—and I think I got them all in front of you—inform and permeate my thinking and, in turn, will permeate the assessment of another gem of a book: Pearls of Functional Algorithm Design ☄

Seldom have I come across a book that was more appropriately named than this one; the reference to pearls is spot on, because this book is a gem in the rough. I seldom hear it mentioned in the programming community, which is a pity, because it has a ton to offer.

But first things first: All examples in Pearls of Functional Algorithm Design are presented in the Haskell programming language, which, by all admissions, is a pure functional programming language. If there is a programming language purer than Haskell, then I’m not aware of it. Then again, I’m decidedly not a language researcher or purist; for that sort of thing, you’ll want to turn to someone like the esteemed Mark C. Chu-Carroll, PhD, author of a delightful book called Good Math (The Pragmatic Bookshelf). Chu-Carroll is—by any objective standard—an inveterate collector of programming  languages 🐚 🐚 🐚

As for me, my tastes are far more pragmatic, guided by my trusty compass that consists of the twin forces of taste and beauty. Yes Sir—and Gentle Lady—I’m a pragmatist to my core. Here’s a telltale clue that will surely give everything away in this area: I think that the Scala programming language is the next best thing since sliced bread 🍞 🍞 🍞 Yes, there is another JVM language in the shape of the lovely Lisp dialect that we know as the Clojure programming language; plus I’ve done plenty of dabbling in Clojure over the years. On top of that, we got lambdas added to the supple workhorse of a language that is Java when Java 8 appeared, yay! But there are only so many hours in a day to keep up with all the cool happenings in the JVM ecosystem, and elsewhere ⏳⏰⌛ Enough said.

Me, I’m more like Indiana Jones, if anyone remembers the intrepid archaeologist and adventurer from the classic movie Raiders of the Lost Ark—in which our nearly-fearless hero is hired by the U.S. government to find the Ark of the Covenant before the enemy does—constantly trying to unearth better ways of going about improving the art of programming, always on the lookout to uncover more intelligent approaches to crafting software, and perhaps trying to decipher the torrential fugues of design-related tactical paradigms in motion that swirl around in seemingly indecipherable patterns, unnervingly so at times. By the way, and lest there be any confusion, I hasten to point out that the preceding musings about software craftsmanship—and software craftswomanship, to be sure—which followed the trailing em-dash above was me speaking, not Professor Jones. Last time I checked, Professor Jones wasn’t that much into software 😉

Okay, so I’m not going to stretch that analogy too much, because it may not hold up for all I know lol. I will, though draw your attention briefly to an absolutely fantastic book—Surfaces and Essences: Analogy as the Fuel and Fire of Thinking (Basic Books) by Douglas Hofstadter and Emmanuel Sander—should you wish to digress and find out just how far analogies can take you on your intellectual journeys.

And trust me, there’s no castle-building going on here; just plain old-fashioned abstract thinking, carved along the contours of what the amazing and legendary physicist Richard Feynman symbolized where his thinking style is on display—as memorably captured in the book entitled Smarter Than You Think: How Technology is Changing Our Minds for the Better (Penguin Press) by Clive Thompson 🚂

When historian Charles Weiner looked over a pile of Richard Feynman’s notebooks, he called them a wonderful ‘record of his day-to-day work‘ to which Feynman demurred

“No, no!”, Feynman objected strongly.
“They aren’t a record of my thinking process. They are my thinking process. I actually did the work on the paper.”
“Well,” Weiner said, “The work was done in your head, but the record of it is still here.”
“No, it’s not a record, not really. It’s working. You have to work on paper and this is the paper. Okay?”, Feynman explained.

Let’s compile our computer programs in our head, shall we? Ready, set, go! It’s Turing machines and lambda calculus all the way down—I kid you not 😉

Feynman the Nobel laureate—he basically transformed the Physics department at Caltech into the powerhouse that it has remained ever since—truly understood that writing his equations and ideas on paper was crucial to his thought.

Let’s now circle back to Pearls of Functional Algorithm Design and hear what Bird has to say about his motivation for putting together this pearly and lustrous book. In Bird’s words

Just as natural pearls grow from grains of sand that have irritated oysters, these programming pearls have grown from real problems that have irritated programmers. The programs are fun, and they teach important programming techniques and fundamental design principles. 
Equational reasoning dominates everything in this book. 

To give you a tantalizing view of the pearls that await you in this oyster, consider its delectable offering by way of the table of content:

Preface page ix
1 The smallest free number 1
2 A surpassing problem 7
3 Improving on saddleback search 12
4 A selection problem 21
5 Sorting pairwise sums 27
6 Making a century 33
7 Building a tree with minimum height 41
8 Unravelling greedy algorithms 50
9 Finding celebrities 56
10 Removing duplicates 64
11 Not the maximum segment sum 73
12 Ranking suffixes 79
13 The Burrows–Wheeler transform 91
14 The last tail 102
15 All the common prefixes 112
16 The Boyer–Moore algorithm 117
17 The Knuth–Morris–Pratt algorithm 127
18 Planning solves the Rush Hour problem 136
19 A simple Sudoku solver 147
20 The Countdown problem 156
21 Hylomorphisms and nexuses 168
22 Three ways of computing determinants 180
23 Inside the convex hull 188
24 Rational arithmetic coding 198
25 Integer arithmetic coding 208
26 The Schorr–Waite algorithm 221
27 Orderly insertion 231
28 Loopless functional algorithms 242
29 The Johnson–Trotter algorithm 251
30 Spider spinning for dummies

Is that an awesome menu, um, table of contents I meant to say, or what? 🍪 🍩 🍮 👜 👝 ⛱

Look, ssshhhh, let’s digress just a tad, and nobody will be the wiser 😴😲

And it’s not that egregious of a digression anyway, since I happened to have noted above that all examples in Pearls of Functional Algorithm Design are presented in the Haskell programming language—so let’s listen to what Guy Steele has to say about Haskell. As longtime readers of my blog know, Steele is one of my programming heroes; he is widely regarded as the father of Common Lisp; and he happens to be the lead author of the Java Language Specification.

Just remember: This digression will be our secret, okay, and we’ll be all good? 😇
Now, to illustrate the flow of the narratives in Pearls of Functional Algorithm Design, take, as an example, the delightful third chapter, which is prosaically entitled Improving on Saddleback Search. The setting is a classroom tutorial on functional algorithm design. There are four students: Anne, Jack, Mary and Theo and we proceed like so, Socratic dialog and all, with the Teacher going first 🎓

Ah yes, charming Socratic dialog and all, with some glimmers, dare I say, of the scintillating magnum opus of a landmark book that many of us affectionately call GEB—for the initials in Gödel, Escher, Bach: An Eternal Golden Braid—by the Pulitzer Prize-winning author Douglas Hofstadter. Remember how we were regaled in GEB with mind-bending dialogs between crabs and ants and stuff? 🐌 🐜 🐊 🐝 🐚

Well, back to Pearls of Functional Algorithm Design, allow me to ask: Were you starting to think thoughts such as the following? Groan, a tome with strong functional programming undercurrents—surely we need to brace ourselves for a deadly boring treatise? So let me comfort you by saying, Trust me on this one; not a trace of boredom anywhere in sight with this gem. What you’ll be in for is a delightfully pleasant surprise of discovering algorithmic excellence from the functional point of view 🎈

This book will, as it were, grab your imagination and whisk you away to Neverland, in the fabulous tradition of Peter Pan 🌈 Here are other candid thoughts that I jotted down earlier during recent transcontinental transit—I wrote the bulk of this essay while flying from Austin to San Diego. Hmm… That might explain the the flight of fantasy with which we had a brief skirmish above. Some other thoughts are as follows 🌹

You will see the elegant mathematical machinery neatly unpacked and put together again—something that Humpty Dumpty failed at after he had had a great fall from the wall—to see exactly what it is that makes an intricate (functional) algorithm  tick. Remember, too, how four-score men and four-score more, could not make Humpty Dumpty where he was before, alas 🐓 But hey, that was then, and this is now 🎉

Fear not, though, intrepid reader! The mathematical machinery—which ably accompanies the narratives in Pearls of Functional Algorithm Design to marvelous effect—is both packed and neatly unpacked without a hitch, whew. And yes, Bird pulls no punches; yet he neither talks down condescendingly nor resorts to hand waving nor dumbs things down. This book hit the sweet spot for me 🍯 It’s simply marvelous in a delicious way.

The presentation is pleasing, broken down into digestible chunks: aptly annotated code snippets, helpful tables, elegant mathematical underpinnings that have neatly been drawn into a cohesive narrative. Pearls of Functional Algorithm Design is, alas, sorely lacking in the illustrations department. This was a bit of a letdown for visually oriented designers and programmers like me—should you wish to see everything that a book can be, firing on all cylinders, as it were, look no further than the tour de force entitled The Nature of Computation (Oxford University Press) by Cristopher Moore and Stephan Mertens, on which I have lavished much attention elsewhere, in the first installment of this series of essays, in fact 🌿

While The Nature of Computation did not come in at the first spot—I valiantly resisted putting it in the first spot, sorely tempted though I was—simply because I would be doing a disservice to my readers by pointing them in the direction of a book that, awesome as it is, is not an introductory one. Think classical utilitarianism ala Jeremy Bentham and John Stuart Mill who held that we ought to maximize the good, that is, bring about “the greatest amount of good for the greatest number“.

The pearls in this book—the brute force algorithms—are progressively rewritten into their increasingly efficient counterpart algorithms. The way this is all wrought, the manner in which the intermediate steps are crafted, is something to behold, and I really shouldn’t take away your excitement prematurely, oh no 🔦

Dig in, and you’ll see what I’m talking about. As a prelude, you may also wish to look at precisely this sort of transformational craftsmanship on glorious display—albeit from the distinctly different yet equally venerable object-oriented perspective—in the astonishingly good book Refactoring to Patterns by Joshua Kerievsky (Addison-Wesley Professional) as I’ve tried to capture in an essay elsewhere 🍎 🍰

This is a book for someone who likes to think. If that’s you, don’t miss Pearls of Functional Algorithm Design 🍒

9. How to Think About Algorithms (Cambridge University Press) by Jeff Edmonds 🌴

Next up, we have a book that’s drenched in a remarkably creative approach to teaching algorithms: How to Think About Algorithms (Cambridge University Press) by Jeff Edmonds. I have not seen a book quite like this—on the subject of algorithms or otherwise—anywhere else!

People that I’ve talked to have referred to How to Think About Algorithm as a life changer. What many have—myself prominently included—appreciated a lot about this book’s approach is its uncompromising devotion to studying a number of well-known algorithms that solve important problems, presenting the associated pitfalls, going over several ways to solve the problem at hand, even when intuition contradicts reality, and finally explaining the correct solution 💯
The author, Edmonds, capture the gestalt of this book rather nicely in the highly detailed preface to the book by breaking up his recommendations to studying How to Think About Algorithm into easily digestible chunks, grouped under apt headings.
Fancy that, I’m caught quoting myself in a virtual act of self-referential circularity; goodness, maybe next we’ll be contemplating Salvador Dali’s melting watches and stuff ⏰⏳⌛🎁

This book is a creative whack on the side of one’s head. To illustrate this point, lest you think that I’m engaging in psychobabble, consider this typical piece of advice from the pages of How to Think About Algorithm—and this fine book is liberally sprinkled with such similar nuggets of wisdom—on how to use the metaphor of analogy as a guide.

Did that grab your interest? It sure grabbed mine when I first read How to Think About Algorithms, ages ago, since which time I’ve revisited its pages many times over 🎻 I believe that How to Think About Algorithm will make an awesome second book on algorithms; it may be a bit much to digest as your very first introduction to the exciting world of algorithms.

 

10. Algorithms Unplugged (Springer) by Berthold Vöcking et al 🌲

Last, but certainly not the least, is another remarkable book on algorithms: Algorithms Unplugged (Springer) by Berthold Vöcking et al. Don’t overlook this cool book or let its seeming simplicity put you off; true, a non-computer science individual could, with some effort, pick it up and run with it, without running into too much difficulty in understanding how algorithms work 🎯

I’m not aware of a kinder, gentler approach to introducing yourself to the study of algorithms. For example, consider this typical piece of guidance, all of it gently carved into easily digestible, yet solidly intelligent chunks—Here, Heribert Vollmer and Dorothea Wagner (both are among the contributors to this nicely eclectic book) are giving an overview of Optimization in Part IV of the book.

So it is that I will now exit, but not before an admittedly flamboyant flourish that harkens back to the 1937 Disney classic, Snow White and the Seven Dwarfs, in which the Evil Queen utters the famous line that I’m here taking the liberty of wildly paraphrasing—with a nod to Godin’s moniker that “Real Artists Ship”—by intoning

Magic mirror, on the wall—which one is the fastest shipping method of them all?
🚂 🚃 🚚 🚢 🚅

In the end—and much as I hinted at, at the outset—I invite your comments. Equally importantly, please, do please consider helping our fellow Americans who are bracing themselves for the fury of Hurricane Irma.

I’ll mention this as a friendly reminder—your comments are welcomed, as always—that having read my brief take each on a handful of the finest algorithms books…

    • Did you find that your experience of reading these books was perhaps different? 
    • Were there other qualities, perhaps, that I did not cover, and which happen to be the ones that you found the more helpful—in these or other books—as you mastered algorithms? 
    • Did I leave out any of your favorite algorithms books?!
    • I’ve covered only a tiny fraction of the algorithms books that I’ve read, necessarily limited by the time available—stay tuned for future installments of this essay 

I trust that these brief vignettes will help you in some small way along your journey to grokking algorithms 🚣 And yay, we made it through a whole essay without my digressing much—now fancy that. And now that we’re done with the, ahem, essay proper, however, we surely can digress a tad, can’t we? 😂

Woohoo, here we go ⛷

See, didn’t I tell you that while I may be recalcitrant at times, when it comes to digressingI try to do so with often a method to my madnessI’m hopefully not that incorrigible, and people who know me hardly think of me as a curmudgeon 😇

With that, I rest my case; now you tell me if I made good on my promise that —unlike the previous installment where digressions were center squaredigressions were going to appear only after the essay proper 🐝

In the end, and in no particular order, here then is a fine set of yet other books on algorithmsand data structures, to be sure—which I had in mind when I sat down to scribble some musings on the subject of algorithms, a subject that ever remains near and dear to my heart 💝

In a properly automated and educated world, then, machines may prove to be the true humanizing influence. It may be that machines will do the work that makes life possible and that human beings will do all the other things that make life pleasant and worthwhile. 

~ Isaac Asimov, Robot Visions

For God’s sake, let us be men, not monkeys minding machines, or sitting with our tails curled while the machine amuses us, the radio or film or gramophone. Monkeys with a bland grin on our faces.
~ D.H. Lawrence, Selected Letters

If you plan on being anything less than you are capable of being, you will probably be unhappy all the days of your life.
~ Abraham Maslow

The art of the bird is to conceal its nest both as to position and as to material, but now and then it is betrayed into weaving into its structure showy and bizarre bits of this or that, which give its secret away and which seem to violate all the traditions of its kind. 

~ John Burroughs

I’ve got the key to my castle in the air, but whether I can unlock the door remains to be seen. 

~ Louisa May Alcott, Little Women

Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition. 

~ Isaac Asimov

And then there was the classic among classics: Tracy Kidder’s unprecedented tour de force

The Soul of a New Machine that was quite the publishing event, and which won a well-deserved Pulitzer Prize, notwithstanding the oh-so-endearing malapropism it engendered 🐣

 

5 comments

  1. – As the author of this blog, I—as a matter of principle—do not edit my essays after posting them; I will, on occasion, revisit and clean up grammatical mistakes, or perhaps add links, update stale links, but that's about it.

    – Having said that, I wished to share some thoughts that are directly related to this post, and which had got inadvertently left out when I wrapped up and posted this essay a few days ago…

    – First, though, I recently received feedback from readers that a lighter-still background for this blog would make it easier on their eyes. As always, I take every bit of feedback seriously in order to make the reading experience around here ever-improving for us all 🙂

    – As I take that feedback into account, I wish to ask: Before the recent makeover of this site, the background theme of the blog was quite a bit darker, but if an even more lighter background theme is preferrable, I’ll look into that and make necessary updates, for sure! Thoughts? Please keep sharing your thoughts, and let's us all make this the best blog site ever!

    – Here, then, are thoughts that are directly related to this post, and which had got inadvertently left out:

    [1] Did I make good on the promise that I had made in saying?:

    "Rest assured that, this time around anyway—unlike the previous installment where digressions were center square—digressions will appear only after the essay proper".

    [2] I shared the table of contents (TOC) for a couple of the books reviewed; was that a help or a redundancy or, worse still, a hindrance? 🙁

    [3] My coverage of the algorithms books—it least as measured by the amount of description that I devoted to each book—was admittedly lopsided. Is that OK, or would you like for the coverage of the books I review in the future be more even (in terms of the amount of description)?

    [4] Last, but certainly NOT the least: I invite you all to please NOT by shy. Please contribute away through your comments. Highly encouraged 🙂

    [5] This is YOUR blog as much as it's mine: I not only write stuff to share with you, I also come back and actually read what I've written, if only to refresh myself on what perspective(s) I had, and shared, at any given time. Our understanding—both individually and collectively—is IMHO constantly evolving and growing

  2. Thank you for the very enjoyable part 2 on Algorithms 🙂

    I liked how in this essay you disclosed a little on your reading methodology (highlighter, tabs etc). I would like to ask more about your methodology, do you read similar sections from each book at the same time ? How do you make effective notes ?

    Some other questions I would like to ask are ;

    What do you think of books such as Cracking the coding interview or Elements of programming interviews ? They aim to teach algorithms in a way to solve problems for interview tests etc ? They are also suppose to be a little easier for newcomers

    Also what are your thoughts on practising algorithmic skills by solving problems on popular websites such as leetcode , hackerrank ?

    For someone that hasn't touched any math since their CS degree, what areas of maths would you say are most important to go other before tackling algorithms ? Would you recommend learning the math as going along or are there any must have pre-cursor topics ?

    Keep up to great work, Thanks

  3. – Thank you, Shahbaaz, for sharing how you enjoyed this essay, Part 2 of Algorithms! I'm delighted that you found it enjoyable

    – What more can a technologist and writer ask for than be accepted and appreciated by their readers 🙂

    – Let's quickly talk about the next installment in this series of essays—yes, I'm now getting a Part 3 of Algorithms into the production pipeline (for this blog) even as I write this response. And what a coincidence it is that got me thinking of doing an essay for Part 3 of Algorithms

    – A handful of additional algorithms books—which prominently includes one of the two you mention, Elements of Programming Interviews by Adnan Aziz et al—were already brewing in my mind, for inclusion in a future installment in this blog series. After reading your comment, I'm convinced that you as well as other readers would benefit from a conversation on those algorithms books, too. A little bird tells me to tell you all: Stay tuned for a future essay 🙂

    – Okay, now to your questions, because I read and give serious thought to every single comment from readers… As to your first comment-and-question ("I liked how in this essay you disclosed a little on your reading methodology (highlighter, tabs etc). I would like to ask more about your methodology, do you read similar sections from each book at the same time? How do you make effective notes?"), let me begin my response by saying that I firmly believe in the philosophy of progressive disclosure, which has guided me well in my career and personal lives, both. Okay, Akram, stop philosophizing already lol 😉

    – So here's the deal: Yes, to sift through the mountains of information that we technologists face every single day—other professionals probably do as well, though perhaps not with the same intensity and sheer volume—we absolutely need a reading methodology to get anywhere with the deluge of information… The times for a stochastic approach are long gone, though probabalistic thinking, albeit in a tangential way, is positively in, and in a big way: So in the spirit of full disclosure, I'll confess that an essay on Deep Learning is in the production pipeline for this blog… Stay tuned.

    – The best way I know of to conquer (seemingly) difficult material is best captured in a really cool (top secret) book to which I'll share a pointer here: Check out How to Win at College: Surprising Secrets for Success from the Country's Top Students by Cal Newport. Via the preceding link, go to the section for Cal Newport (who I ranked in the top spot) and in particular go to the aforementioned book and find Chapter 70 (Study with the Quiz-and-Recall Method), which contains the following stellar piece of advice:

    "You should build your entire approach to studying around the concept that making yourself recall specific information is the absolute best way to learn".

  4. – So I'm a computer scientist who has been practicing the fine art of programming for over two decades. So I would also point you in the direction of the wise words of Edward B. Burger (Southwestern University, Georgetown/Texas) and Michael Starbird (The University of Texas at Austin) who note in their slender yet rich book entitled The 5 Elements of Effective Thinking (Princeton University Press) that:

    "Understand simple things deeply. The most fundamental ideas in any subject can be understood with ever-increasing depth. Professional tennis players watch the ball; mathematicians understand a nuanced notion of number; successful students continue to improve their mastery of the concepts from previous chapters and courses as they move toward the more advanced material on the horizon; successful people regularly focus on the core purpose of their profession or life. True experts continually deepen their mastery of the basics".

    – If I were put on the spot and persuaded—let's here remind ourselves of the delicate yet pragmatic distinction that Winston Churchill drew between the related concepts of "persuading" and "convincing"—to divulge one secret that I guard with my life, that would be it, what I shared above by way of the memorable words from the slender yet deep book entitled The 5 Elements of Effective Thinking (Princeton University Press)

    – I should divulge that I've always been endearingly impressed by the onion-layers-of-conceptualizing metaphor as well as the undertones of constantly revisiting the basics for ever-increasingly faithful conceptualizations. I trace this to my undergrad years when I spent countless hours poring over the mesmerizing pages of the classic MIT textbook, Circuits, Signals, and Systems by William M. Siebert. More details on background can be found here…

    – As to your second question ("What do you think of books such as Cracking the Coding Interview or Elements of Programming Interviews? They aim to teach algorithms in a way to solve problems for interview tests etc? They are also supposed to be a little easier for newcomers…")—which is truly an awesome question BTW—I would say that books in this genre fill an essential gap left by textbooks, such as those that we've seen so far in this series of essays, i.e. Part 1 and Part 2 of Algorithms… These books are indispensable in helping you bridge the gap to landing a great technology job, so there you go.

    – And frankly, one of the two books that you mention, Elements of Programming Interviews by Adnan Aziz et al., is worthy of studying as a classic in its own right. Programming interview prep notwithstanding, it's a fantastic resource of distilled wisdom on all things algorithms, and one that you don't want to miss. Stay tuned for (much) more on it in the next installment in this series of essays—Part 3 of Algorithms 🙂

  5. – Moving on now to your third question ("Also what are your thoughts on practising algorithmic skills by solving problems on popular websites such as leetcode, hackerrank?"), I've got to confess that I'm not familiar with either one of the problem solving popular websites that you mention—now more than ever, I rely on my readers to keep me educated!

    – Okay, so I'm not completely ignorant either, at least I hope not lol 😉

    – With the disclaimer above, let me to point you to two resources, the former being directly related to helping answer your question, and the latter a bit tangentially so. But hey, then again, we're cruising around here on a blog known as Programming Digressions, where a diverse group of readers gathers and shares all
    kinds of interesting ideas at the intersection of culture, software, technology, and science, right?:

    (1) Design Algorithmic Solutions on Project Euler
    (2) Reddit links to a diverse set of related topics…

    – Finally, moving on now to your fourth question ("For someone that hasn't touched any math since their CS degree, what areas of maths would you say are most important to go other before tackling algorithms? Would you recommend learning the math as going along or are there any must have precursor topics?"), which is an awesome question since it got me thinking, so thanks for asking! I say so because I remain smitten, as ever, by trying to find better ways of wielding the power of mathematics that we, as software designers, can bring to bear on our design and craftsmanship work, every single day.

    – I'll have a lot more to say about this, it just so happens, in an upcoming essay on Deep Learning. Meanwhile, suffice it to say that, speaking of the relevance and pervasiveness of math throughout the fabric of science—in particular the math-oriented areas of computer science like deep learning—I can't help but draw parallels to, and resonate with, the marvelously erudite and approachable essay by the Hungarian-American theoretical physicist, engineer, and mathematician Eugene Wigner. It's entitled The Unreasonable Effectiveness of Mathematics in the Natural Sciences. Don't miss it. Again, stay tuned for more in a future essay 🙂

    – So I would draw your attention purposely to Discrete Math and Linear Algebra especially; lots more to follow in a future essay…

    – Last, but certainly not the least, I gratefully acknowledge your gracious words when you say Keep up to great work! Please know that I don't write in a vacuum; I write for my readers, so please you and all, do continue sharing your thoughts—Readers like you make my day, every day, giving me a sense of purpose to continue writing. Let's not let a good thing come to an end 🙂

Your Comment Here!

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