The Best Algorithm Book for Beginner Programmers [2020]

grokking-algorithms-on-table-with-apple

There is a book I am ready to hands-down proclaim as the best book on algorithms.

I claim this for two main reasons:

1) It has cute illustrations and diagrams of cartoon animals.

2) After reading it, I aced the notoriously difficult class, Data Structures & Algorithms.

The best algorithms book for beginners is Grokking Algorithms. The book explains common algorithms with illustrations and easy-to-understand examples.

You may be unsure how it’s possible that a book so short and so cute can be effective at teaching complex topics. But honestly, this book changed my life.

The truth is this: I was scared to take my data structures & algorithms class. I was still ashamed for dropping it the first time.

Years prior, when taking the computer science class at my local community college, writing linked lists in C++ had completely stumped me.

I was at a coffee shop holding my head, pondering how all my variables had the values they had (which, back then, I didn’t know how to use breakpoints 😩), when a non-engineering friend stumbled across me in a coffee shop and remarked in an encouraging tone, “Maybe programming just isn’t for you.”

I was working full-time for an enterprise software marketing company at the time, driving from the San Francisco South Bay to the North Bay to see my boyfriend each weekend. Soon I missed my homework deadlines and dropped the class, and though I hated to think it, I felt like I had proven my friend right: programming wasn’t for me.

So when I took my algorithms class for a second time, I expected to be eaten alive.

Instead, I found that I already understood all of the concepts presented to me: Big O notation, sorting algorithms, linked lists? Easy, easy, easy.

Previous to taking this class, I read an algorithms book for fun, on my nightstand, before going to bed — and I had forgotten about it. But when I took the class for the second time, the same class with the same teacher I had dropped before failing, I discovered the class was now no problem.

This book had a profound impact.

The reason for this impact is what we’re going to talk about in this article.

 


Overview of Grokking Algorithms

Grokking Algorithms by Aditya Y Bhargava is, on the surface, a text that teaches classic data structure and algorithm topics. But the book has a catch: it’s a joy to read! So much so that I read it for fun before even taking an algorithms class. 

The following is a list of many of the topics this book covers:

  • Binary search

  • Big O notation

  • Arrays and linked lists

  • Selection sort

  • Recursion

  • Stacks

  • Quicksort

  • Hash tables

  • Breadth-first search,

  • Dijkstra’s algorithm

  • Greedy algorithms

  • Dynamic programming

  • K-nearest neighbors

  • Trees

  • The SHA algorithm

  • And more!

All of these topics might sound overwhelming and a bit scary for a book with cartoon animal illustrations (and “joy,” as I put it). Also, this book isn’t very long — hovering at around 200 pages.

You may have noticed recursion in the list of topics, which is a mind-bendy concept when first introduced. What if I told you this book explains recursion to complete understanding in about five pages?

 
 

3 Reasons Grokking Algorithms is the best in its field

There’s a reason this book is so effective at teaching.

Here is why Grokking Algorithms is the best algorithms book:

 

#1: Novelty Helps Us Learn

Children have an easier time learning because they find surprises everywhere they go. If we want to learn easier, we must find novelty.

Children have an easier time learning because they find surprises everywhere they go. If we want to learn easier, we must find novelty.

It turns out that cute illustrations are novel. Bringing in that element of the unexpected — along with plain good technical writing — made Grokking Algorithms a joy to read.

If you’ve read my other articles, you know that I am obsessed with the Head First series by O’Reilly Media. Every first chapter of a Head First book describes the importance of novelty in learning.

In my free email course, Get the Most from Technical Books (For Programmers), I tell my students don’t read bad technical books. They should instead be looking for the book with the mouse drawings, since that book understands that textbooks are meant for learning more than for sleeping.

Because each Head First book explains it so well, I’m just going to put the whole section here:

Your brain craves novelty. It’s always searching’s scanning, waiting for something unusual. It was built that way, and it helps you stay alive.

So what does your brain do with all the routine, ordinary, normal things you encounter? Everything it can to stop them from interfering with the brain’s real job — recording things that matter. It doesn’t bother saving the boring things; they never make it past “this is obviously not important” filter.

How does your brain know what’s important? Suppose you’re out for a day hike and a tiger jumps in front of you — what happens inside your head and body?

Neurons fire. Emotions crank up. Chemicals surge.

And that’s how your brain knows…

This must be important! Don’t forget it!

So there you have it: how cute cartoons can get you an A in your Data Structures class.

#2: The Illustrations Are Optimized for Your Brain

Learning science backs up the tactics used in  Grokking Algorithms , which includes visuals and text that rely on each other to tell the whole story.

Learning science backs up the tactics used in Grokking Algorithms, which includes visuals and text that rely on each other to tell the whole story.

It’s really not just the illustrations. It’s the writing and the illustrations.

If you have taken any college writing class, you may have been assigned Elements of Style, commonly referred to by the authors, “Strunk & White”.

This is its most famous rule:

Omit needless words.

Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.

I bring this up because I want you to note both the words and the illustrations in the following excerpt from Grokking Algorithms. Click the images to see a larger view:

This section is telling a story: it sets the scene (“you go to a show and need to check your things”) and presents an image, marking each step of the narrative.

Notice the details presented in the illustrations. The text is clean and specific, yet the illustrations show humor.

A handful of novel details that keep my interest:

  • The fancy frills on the chest of drawers. These drawers have elevated value. Also just the strangeness of the idea of checking things into a set of drawers.

  • The man in a funny mustache and bow tie who opens the drawers and uses the formal French address ‘monsieur’.

  • The man in the funny spotted turtleneck sweater, requesting the number of drawers.

  • The drawers store an umbrella (a practical item) and a bunny (an impractical item!).

  • The bunny’s position in the drawer and its expression! 😂

By the time we get to the final illustration, we see the chest of drawers from another angle, but now it resembles what we would traditionally see in an explanation of memory in a computer science course: a grid of squares, and a label of the computer-generated address.

While this explanation of memory takes little real estate in the book, it conveyed a lot: it gives its readers a visual mental model of memory that sticks.

 

#3: It Talks Directly To You

Grokking Algorithms  uses a conversational style, which is the best way to keep us engaged.

Grokking Algorithms uses a conversational style, which is the best way to keep us engaged.

Have you watched the show for preschool children, Blue’s Clues? According to Wikipedia, it “has been described as the first commercial television show for preschoolers that was both educational and profitable.” It’s mind-blowing that an educational show for preschoolers had massive popularity like that, and it even got a reboot in 2019.

The stuff in Blues Clue’s was revolutionary and that’s because it was both educational and fun. It was conversational and spoke directly to ‘you’, asking questions without ever talking down — even though the audience was composed of 5 year olds.

When I was in high school, I wanted to be a children’s book author.
I found a successful children’s book author to mentor me, and he took me to the book store and taught me how to read children’s books critically. Like he taught me to, I spent plenty of time in the children’s book sections of bookstores trying to deconstruct them in my head.

But my interests weren’t always understood by my peers. It seemed that because I was actively reading and emulating the simple language of books geared toward children, I was portraying an immature intellect myself.

But a Master of Arts in literature and a career in enterprise software later — I still haven’t outgrown my “children’s book phase.” Children’s literature has a thing that is universally appealing, and it normally takes until parenthood for adults to discover this.

This is what I think: we have spent decades perfecting education and entertainment for children, but what we got right for children we are not yet getting right for adults.

Think about it: our mechanisms for learning are just the same as for small children. Children are master learners, and while what we strive to learn is far more complex than that of children, how we learn is innate. We ought to embrace what children’s education can teach us about adult education.

I am not saying that Grokking Algorithms is a children’s education book, but it uses educational tools that we more frequently find in children’s literature than we find in adult texts.

Referencing the excerpt from the previous section, you notice that the text is speaking to ‘you’ and it is instructing ‘you’ to walk through those steps.

The book also asks tons of questions. Here is just a sample of them:

Every day, you write down everything you spent money on. At the end of the month, you review your expenses and sum up how much you spent. So, you have lots of inserts and few reads. Should you use an array or a list?

Suppose you have a bunch of music on your computer. For each artist, you have a play count.

You want to sort this list from most to least played, so that you can rank your favorite artists. How can you do it?

Suppose you’re running a voting booth. Naturally, every person can vote just once. How do you make sure they haven’t voted before?

Each of the examples are easy to grasp and practical. And while I didn’t include them here, they are often accompanied by an illustration. The questions often have some form of a natural separator, whether that be a page turn, a transition to a new section, or an illustration.

Because the book has so many ‘beats’ — lots of line breaks, illustrations, and section headers — it’s easy to slow down and think with the book, as if you’re having a real conversation.

 
 

Review Snapshot

This review snapshot covers all the basics you need to understand about this book: the audience that suits this book best, its affordability, how much value the book brings, and most importantly, how fun the book is to read. Since after all, books on programming ought to be fun to read.

Main Audience: “Beginning Coder”

You’ve taken an introduction to programming course or are self-taught in programming concepts such as variables and conditionals. That, or you did already take a data structure & algorithms course, but the material flew by and you’re not sure if you actually learned it (and don’t be shy if you’re in this camp; I know plenty of people who are). This book is great for first-time learners or those looking for a review.

Affordability Score: “Cheaper than the Average Textbook”

As of this writing, Grokking Algorithms on Amazon is a few dollars cheaper than its retail price of $45 USD. This book has the benefit of being on the market for awhile, so there’s plenty of used and library copies as well.

Value Score: “A Gourmet Feast”

I say ‘gourmet’ because I needed a way to say that the book is packed with goodness on every page, but elegantly. It’s not long and light, like in my review of the nearly-800 page The Complete Software Developer’s Career Guide. Algorithms is at around 250 pages. Each page has plenty of white space and illustrations, but the complex topics are explained simply, making each page have extremely high value.

Fun Score: “An Absolute Joy”

I think books that max out the Fun Score should have a prize: like a badge or something. At Books on Code, we find resources that go above and beyond, that spark curiosity, creativity, and joy. We do not read programming books just for the utility of it, but to fuel our imagination in solving problems and help us realize our potential as programmers.

Grokking Algorithms is an absolute joy to read — no understatement. To further attest to this, my time for reading Algorithms was in bed before going to sleep, and reading algorithms kept me engaged past my bedtime. This is a feat most programming books cannot claim.


If you liked this article, don’t forget to share it with the programmers in your life.

If you like me, Miranda, and want to hear more of my stories 😁, sign up for my newsletter below this article. I write to you each week about Books on Code like you’re my best friend — because maybe you are!

And if you want to experience more joy when reading technical books, you can sign up for the free Books on Code email course, Get the Most for Technical Books. 📚

If you are interested in a more hands-on, instructional approach to programming with graded assignments and all, I cannot recommend Coursera’s Fundamentals of Computing by Rice University highly enough. The courses cover “much of the material that first-year Computer Science students take at Rice University.” And being honest — I got far more from this than I did my local university curriculum. (But still keep Grokking Algorithms at your nightstand.)

And lastly, thank you so much for being here with a thirst to learn and become the best software developers you can be. By being here, you’re helping me become a better developer, too, so thank you from the bottom of my heart.

If you’re interested in learning more of the skills needed to pass a coding interview, then you will love the article on Cracking the Code Interview. I will see you there. 👋 🙂

 

Miranda Limonczenko

Miranda is the founder of Books on Code, with a mission to bring book-lover culture to programmers. Learn more by checking out Miranda on LinkedIn.

http://booksoncode.com
Previous
Previous

Why You Should Stop Freeloading and Pay for Your Programming Books

Next
Next

How to Read Programming Books