BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles Grokking Algorithms Review and Author Q&A

Grokking Algorithms Review and Author Q&A

Key takeaways

  • This book aims to show readers new ways to solve problems.
  • This book attempts to leverage illustration to make it easier to grasp topics that could be otherwise impenetrable for some.
  • This book can be useful not only to people without previous exposure to algorithms, but also as a refresher for computer science graduates.
  • This book also provides many examples and simple exercises.
  • This book is not a reference, rather a practical book. It only contains algorithms that proved useful in the author's daily practice of programming.

 

Manning’s Grokking Algorithms, written by Aditya Y. Bhargava, takes a novel approach to introduce such complex matters as data structures, algorithms, and complexity. Himself a visual learner, Bhargava explains he attempted to leverage the powerful expressiveness of illustration to make it easier to grasp topics that could be otherwise impenetrable for some.

The book assumes that readers already know the basics of coding. According to Bhargava, it could be useful not only to people without previous exposure to algorithms, but also as a refresher for computer science graduates.

The first three chapters in the book cover the foundations, including topics such as Big O notation and recursion. Readers are given the first examples of data structures, including arrays and linked lists, and algorithms, including binary search and selection sort.

Chapter 4 introduces the divide and conquer problem solving technique and exemplifies this approach through the quicksort algorithm.

Chapter 5 to 7 are devoted to hash tables and graphs. Besides going into a detailed description of both hash tables and graph, the book strives to provide meaningful use cases that can drive their adoption. Hashes’ collision and performance are covered, as well as how to choose a good hash. For graphs, both breadth-first and Dijkstra’s shortest path algorithm are presented.

Chapter 8 and 9 go back to basic problem solving by presenting greedy algorithms and dynamic programming. Greedy algorithms are introduced in the context of NP-complete problems, which get a fairly basic coverage. Both the greedy and the dynamic approaches are described in the context of classical problems such as the traveling salesperson, knapsack, etc.

Chapter 10 presents K-nearest neighbors (KNN), a machine learning algorithm that is used for clustering, i.e. grouping data points based on some definition of distance so they are “close together”. This chapter provides a very light introduction to the basic ideas behind machine learning.

Finally, chapter 11 goes over 10 algorithms that provide a good ground for further exploration. Among the covered algorithms are tree-based search, inverted indexes, Fourier transform, map-reduce, SHA hashing, and a few others.

Throughout the book, illustrations are used to explain every significant concept. Particularly interesting are the illustrations used for abstract concepts, such as recursion or divide-and-conquer, etc. Besides accompanying each concept and explanation with illustrations, the book also provides many examples the reader is invited to build and execute, and simple exercises that provide a way for readers to assess their understanding before going further. The book provides solutions to all proposed exercises in the final chapter. All code samples use Python.

InfoQ has spoken with Aditya Bhargava to learn more about his book.

InfoQ: Could you explain the motivation to write this book? Beyond being an illustrated book, what differentiates it from other books about algorithms?

Aditya Y. Bhargava: I focus on ways to make the content easier to read. For example, one of my writing principles was “just in time vs. just in case”. Often tech books will throw lots of concepts at the reader, whether they are useful or not. This is “just in case” teaching. I’ll tell you this just in case you need it. My book focuses on “just in time” teaching: I tell the reader only what they need to know right now. So my examples tend to be short and to the point.

InfoQ: Could you shortly describe your background in computer science and your interest in algorithms?

Bhargava: I’m a self-taught programmer. I started by making games in Basic and then in ActionScript. I struggled to understand algorithms until one of my teachers made the topic really clear for me. That’s when I realized that algorithms aren’t that hard if they are explained well.

InfoQ: How did you come to the idea of an illustrated book about algorithms? In what ways do drawings help explain and understand algorithms?

Bhargava: I’ve been writing illustrated blog posts on my blog since 2013. I get a lot of nice comments from readers, saying that the illustrations make the concepts very clear. Manning approached me about doing an illustrated book, and I thought algorithms would be a good fit. They are such abstract concepts but the drawings make them concrete.

InfoQ: At first glance, your book is mostly of appeal to programmers with little previous knowledge about algorithms. Do you think the book could be interesting for developers that have had a formal introduction to algorithms as well? What value does your book bring to them?

Bhargava: A lot of people like my chapter on dynamic programming. Even with a formal education, I think dynamic programming can be hard to understand. We spent a lot of time writing an “FAQ” section for that chapter to clear up a lot of the hard parts of dynamic programming.

Some people like my examples. It is hard to come up with good examples to explain these topics, so my book is useful if you want to teach these concepts to others.

InfoQ: What should readers of your book expect from your book? What should they not expect?

Bhargava: My book will show readers new ways to solve problems. So readers can expect to expand their toolkit, and they should be able to solve some problems they couldn’t before.

I only chose practical algorithms for the book, so every chapter in here is useful. For example, I didn’t include “insertion sort”, a very popular sorting algorithm, because it won’t help readers do their jobs any better. So readers should not expect a reference book. That would have bogged down the book with a lot of useless content.

InfoQ: What advice would you give to a programmer without previous knowledge about algorithms who decide to tackle this somewhat hard field by reading your book?

Bhargava: Make sure you do the exercises! Most of them are easy to do (a couple minutes), and they will help you make sure that you understand the content.

InfoQ: Algorithms constitute a vast field. What criteria guided you in your selection of what to present and what to exclude?

Bhargava: I picked algorithms that have been most helpful to me in my daily job. And I picked algorithms that didn’t require a lot of knowledge up front.

InfoQ: Which algorithm was the most fun for you to illustrate? Which one the hardest?

Bhargava: It was fun to illustrate divide and conquer, since it is such a visual idea. It was hard to illustrate dynamic programming, because it was hard to keep track of the values in the boxes.

InfoQ: Where there any algorithms that you would have liked to include into your book but did not make it for whatever reason?

Bhargava: Yes! I have a whole chapter that lists ten algorithms that I would have liked to include. I really wish I could have included linear programming, because it is so powerful.

InfoQ: Finally, what is your advice for readers of your book interested in going deeper into algorithms? What would be their next steps?

Bhargava: There are tons of online resources! Blogs: adit.io (my blog), betterexplained.com. Coursera’s course on Machine Learning is very good too.

About the Book Author

Aditya Bhargava is a Software Engineer with a dual background in Computer Science and Fine Arts. He blogs on programming at adit.io.

Rate this Article

Adoption
Style

BT