Book Review: Grokking Algorithms, Second Edition by Aditya Y Bhargava
I'm a developer from India, who is blind and loves to know how computers work at every level.
Introduction:
Grokking Algorithms is a book by Aditya Y Bhargava. The book teaches algorithms with an informal tone with a lot of illustrations to accompany the explanations. The first edition of the book came out in 2016, and the second edition was published in February of 2024. The publisher of the book is Manning. This review will focus on the second edition.
My review:
First, a confession.
I'm not usually a fan of judging a book by its cover. In my case, since I can't see, I suppose it should be judging a book by its title. Even though it results in me reading books that are worthless sometimes, that is something I strictly follow because it usually results in discovering a great amount of knowledge that I wouldn't be able to find otherwise.
But that is exactly I ended up doing in the case of this book. Being blind, I usually try to stay away from the books featuring a large number of illustrations, since they usually do not help me at all. In recent times, I've even come across books which put the code in an image instead of the page itself, adding extra difficulty for me.
Now, maybe I judged this book too early. Which is why I ended up avoiding it when every book list about algorithms seem to recommend it. I will talk about the illustrations later in the review, but I wanted to get this point out of the way.
The book has 13 chapters in total. The first chapter starts out with an explanation of Binary Search algorithm, along with an explanation of Big O notation and why exactly it is used. Chapters 2 and 4 focus on sorting, with Selection Sort and Quicksort respectively. The third chapter is focused on recursion.
Honestly, I haven't done recursion for a while, so it was nice to refresh my knowledge about it.
Chapters 5, 7, and 8 are focused on data structures: Hash Tables and various Trees. Chapter 6 is focused on Breadth-first search.
Apart from this foundational stuff, there are strategies like divide and conquer, Greedy algorithms, and dynamic programming. Their explanations are nice and easy to understand.
Take this example of a list:
Websites with top-10 lists sometimes use this tactic to get more page views. Instead of showing you the list on one page, they put one item on each page and make you click Next to get to the next item in the list. For example, Top 10 Best TV Villains won’t show you the entire list on one page. Instead, you start at #10 (Newman), and you have to click Next on each page to reach #1 (Gustavo Fring). This technique gives the websites 10 whole pages on which to show you ads, but it’s boring to click Next nine times to get to #1. It would be much better if the whole list was on one page and you could click each person’s name for more info.
Notice how easy it is to grasp this explanation. You have the start of the list, which can lead you to the second item in the list. Once you go there, now you have two points to remember: next, which will take you to the next page, and previous, which will take you back to the previous page. I was quite angry after reading this example because such sites write two or three lines on each page and then you go to the next page to read even more brain-rotting basic information.
Getting back to the book, every chapter has exercises, some have more, others have less. These exercises are located right in their own sections, instead of being located at the end of the chapter. In this way, the book is just like one of my favorites: The C Programming Language.
None of the exercises ask you to write the code. In case if you are like my earlier self, thinking that writing code is the only important thing, then I urge you to reconsider. Yes, you are focusing on the theory. However, writing down answers to the questions asked in the exercise helps you formulate your thoughts more clearly. It would be helpful during an interview to explain your approach to solving a particular problem in a better and clearer way for example.
The Illustrations didn't get in my way for the most part. Except for the chapters concerning with graphs and trees section. Even during the exercises, there was an image given in the question, and the answer had to be given based on the information available on that image. So, I read those chapters but didn't bother with the exercises there.
Granted, the illustrations do show up on other chapters in the questions, especially on the later chapters. But their number is low. I still skipped those exercises, but it didn't impact me much. The real negative impact was in the graphs and trees chapters, so that was a downer.
But that is not the fault of the author. Visual topics like these are notoriously difficult to make accessible for a visually impaired person, resulting in difficulty with geometry and graphs in the math subject. So, there is no reason why it would be any different here either.
Despite this downside, I think this book is extremely approachable, and it gives you a solid start to learning algorithms. Sure, you won't be becoming a powerful sorcerer just by reading this book, but it will get you started on the right path so you can tackle the difficult tomes without getting lost. Who knows? Maybe you might give some of those competitive mages a run for their money on platforms like Usaco and CodeForces?
So, the book is heavily recommended from me. It is easy and approachable. You don't have to be working in the IT field to understand its explanations, so pick it up, it will definitely help you.
That's it for this review. Check out my review of First and Last Freedom by Jiddu Krishnamurti, and my web serial novel here. It is just about to end, catch up on the final few chapters!
-Tanish.