Grokking Algorithms Review: The Friendliest Way Into Algorithms

Grokking Algorithms by Aditya Bhargava

Author: Aditya Bhargava · Published: 2016 · Genre: Programming, Algorithms

Grokking Algorithms‘s biggest strength is its hand-drawn illustrations, which make binary search, recursion and graph search genuinely easy to picture. Its biggest limitation is depth: it skips proofs, covers few data structures and leaves out topics you’d need for a computer science course or serious interview prep. It’s the best first algorithms book for self-taught programmers, bootcamp graduates and anyone scared off by thick textbooks.

Source code on a computer monitor, seen through a pair of eyeglasses resting in front of the screen
Source code on a computer monitor, seen through a pair of eyeglasses resting in front of the screen. Photo by Kevin Ku on Pexels.

The core ideas

  • Big O as a way to compare growth. Bhargava opens with binary search. Guessing a number between 1 and 100 by halving the range each time takes at most seven guesses, while checking numbers one by one could take 100. That gap between O(log n) and O(n) is the book’s first lesson, taught with pictures rather than proofs.
  • Arrays versus linked lists. Arrays give fast reads by index; linked lists give fast inserts and deletes. Selection sort, which runs in O(n²) time, shows why these choices matter.
  • Recursion and divide and conquer. Every recursive function needs a base case and a recursive case, and the book draws the call stack so you can see it grow and shrink. Quicksort follows: pick a pivot, partition, recurse. It averages O(n log n) but degrades to O(n²) with bad pivots.
  • Hash tables. Fast lookups, caching and duplicate detection, plus collisions and load factor, explained with everyday examples like looking up prices at a grocery store.
  • Graphs. Breadth-first search finds the shortest path in an unweighted graph; the book’s example is searching your friends, then their friends, for a mango seller. Dijkstra’s algorithm handles weighted graphs, and the book warns that it doesn’t work with negative-weight edges, where you need Bellman-Ford instead.

Later chapters cover greedy algorithms and NP-complete problems such as set cover and the traveling salesperson, dynamic programming through the knapsack problem and longest common substring, and k-nearest neighbors.

What’s great

  • The pictures do real work. The drawings of recursion and the call stack are the clearest beginner explanation of the topic I’ve seen.
  • Short, focused chapters. Each teaches one idea, with exercises and answers, so it’s easy to read a chapter a night.
  • Honest about trade-offs. It keeps asking which option is faster and when, instead of presenting one right answer. That habit is what transfers to real work.
  • Runnable code. Examples are short Python, and the book’s companion repository has versions in many other languages.

What’s weak

  • Shallow by design. There are no proofs of correctness and little analysis beyond Big O intuition. The first edition treats trees only as a pointer in its final chapter, and heaps barely appear.
  • Dynamic programming feels rushed. The worked grids are clear, but many readers finish able to fill in that one table rather than spot DP problems on their own.
  • Aging code. The first edition’s examples use Python 2, which is now obsolete.
  • Not enough for interviews. It gives you the vocabulary, but you’ll need plenty of practice problems and a deeper book to pass a demanding technical interview.

Who should read it

Read it if you code but never studied computer science, or if you’re starting a CS course and want intuition before formalism. Get the second edition (2024), which moves the code to Python 3 and adds chapters on trees, balanced trees and B-trees. Then move on to something heavier, such as Sedgewick and Wayne’s Algorithms or Skiena’s The Algorithm Design Manual.

Rating: 4/5

Image credits — Featured image: Image by jmerelo via Flickr, CC BY-SA 2.0, cropped. In-article images: Photo by Kevin Ku on Pexels.