A friendly, fully-illustrated introduction to the most important computer programming algorithms.
Master the most widely used algorithms and be fully prepared when you’re asked about them at your next job interview. With beautifully simple explanations, over 400 fun illustrations, and dozens of relevant examples, you’ll actually enjoy learning about algorithms with this fun and friendly guide!
In Grokking Algorithms, Second Edition you will discover:
Search, sort, and graph algorithmsData structures such as arrays, lists, hash tables, trees, and graphsNP-complete and greedy algorithmsPerformance trade-offs between algorithmsExercises and code samples in every chapterOver 400 illustrations with detailed walkthroughs
The first edition of Grokking Algorithms proved to over 100,000 readers that learning algorithms doesn’t have to be complicated or boring! This revised second edition contains brand new coverage of trees, including binary search trees, balanced trees, B-trees and more. You’ll also discover fresh insights on data structure performance that takes account of modern CPUs. Plus, the book’s fully annotated code samples have been updated to Python 3.
Foreword by Daniel Zingaro.
Purchase of the print book includes a free eBook in PDF and ePub formats from Manning Publications.
About the technology
The algorithms you use most often have already been discovered, tested, and proven. Grokking Algorithms, Second Edition makes it a breeze to learn, understand, and use them. With beautifully simple explanations, over 400 fun illustrations, and dozens of relevant examples, it’s the perfect way to unlock the power of algorithms in your everyday work and prepare for your next coding interview—no math required!
About the book
Grokking Algorithms, Second Edition teaches you important algorithms to speed up your programs, simplify your code, and solve common programming problems. Start with tasks like sorting and searching, then build your skills to tackle advanced problems like data compression and artificial intelligence. You’ll even learn to compare the performance tradeoffs between algorithms. Plus, this new edition includes fresh coverage of trees, NP-complete problems, and code updates to Python 3.
What’s inside
Search, sort, and graph algorithmsData structures such as arrays, lists, hash tables, trees, and graphsNP-complete and greedy algorithmsExercises and code samples in every chapter
About the reader
No advanced math or programming skills required.
About the author
Aditya Bhargava is a Software Engineer with a dual background in Computer Science and Fine Arts. He blogs on programming at adit.io.
Table of Contents
1 Introduction to algorithms
2 Selection sort
3 Recursion
4 Quicksort
5 Hash tables
6 Beadth-first search
7 Trees
8 Balanced trees
9 Dijkstra’s algorithm
10 Greedy algorithms
11 Dynamic programming
12 k-nearest neighbors
13 where to go next
From the Publisher





Publisher : Manning
Publication date : March 26, 2024
Edition : 2nd
Language : English
Print length : 320 pages
ISBN-10 : 1633438538
ISBN-13 : 978-1633438538
Item Weight : 1.2 pounds
Dimensions : 7.38 x 0.5 x 9.25 inches
Best Sellers Rank: #33,315 in Books (See Top 100 in Books) #3 in Computer Programming Languages #16 in Python Programming #31 in Software Design, Testing & Engineering (Books)
Customer Reviews: 4.7 4.7 out of 5 stars (212) var dpAcrHasRegisteredArcLinkClickAction; P.when(‘A’, ‘ready’).execute(function(A) { if (dpAcrHasRegisteredArcLinkClickAction !== true) { dpAcrHasRegisteredArcLinkClickAction = true; A.declarative( ‘acrLink-click-metrics’, ‘click’, { “allowLinkDefault”: true }, function (event) { if (window.ue) { ue.count(“acrLinkClickCount”, (ue.count(“acrLinkClickCount”) || 0) + 1); } } ); } }); P.when(‘A’, ‘cf’).execute(function(A) { A.declarative(‘acrStarsLink-click-metrics’, ‘click’, { “allowLinkDefault” : true }, function(event){ if(window.ue) { ue.count(“acrStarsLinkWithPopoverClickCount”, (ue.count(“acrStarsLinkWithPopoverClickCount”) || 0) + 1); } }); });
13 reviews for Grokking Algorithms, Second Edition
Add a review
Original price was: $49.99.$35.99Current price is: $35.99.


Jorge Alfaro –
Excellent book
This book is an excellent resource for beginners and even for those who simply want to refresh their understanding of certain concepts.
Narawit Tubtimtoe –
Good introduction book so far, even good refresher of the algorithm topics. Well done
The book is really concise about the topic and can simplified the complex topics really well. Worth the time to read
Ramiro –
Love it
I liked reading this book. I only wish I had this back in college.It is a nice refresh of knowledge. It’s quite basic though.
JP –
Easy to follow
A good basic introduction with drawings to explain the information. Wish it was more expansive with additional topics.
Creative Identity –
Excellent resource
Excellent resource for those starting their journey to writing mature code.
Sam –
Fascinating book
Very well written and interesting
Aaron Kim –
Good Basics
A great reintroduction and way more effective and comprehensive than grinding leetcode
zachary –
Good book.
The information was great for a beginner level.
Alex –
I don’t have much algorithm experience, so I was nervous about starting this book. It turned out to be really easy to follow. The pictures and simple explanations made it much less confusing than I expected. Each chapter builds up slowly; the examples helped me see how things work. The exercises weren’t too hard, and I liked that the code is in Python, which is beginner-friendly. This is a great place to start if you’re new to this topic and want something that doesn’t feel overwhelming.
Pietro De Domenico –
There is no way around this, this book is incredibly good.It explains some base, yet key, data structures and algorithms in a way to is fairly simple to comprehend; the illustrations allow you to visualize the structure of the data structures in a far more organic way than just looking at a wall of code, while also allowing you to follow step by step the flow of the algorithms.This, completed with the code given, allow you to learn and comprehend fairly quickly the contents inside, and trust me, this book is both an eye opener to a whole new world of incredibly interesting things to learn and demystifies an entire new branch of IT that goes from “impossibly hard” to “it wasn’t that bad”.Furthermore, when required, the book also explains the underlying computer architecture that favors one type of structure and algorithm based on another. If you read this, you will know why reading from an array is faster than a linked list, but also why writing to it might be incredibly fast or far slower, depending on which situation. Aside from this example, this kind of knowledge allows you to make far more informed decisions.The only slightly negative, but debatable point, is the choice of the language Python.On one hand, this book being in Python instantly becomes accessible to everyone, even without any Python experience grasping the content is incredibly easy.On the other hand, I feel like some concepts will always remain purely hypothetical if you do not have to implement them.For example, the linked list vs array example made before is completely transparent if you use Python, because you do not have to deal with the underlying structure, which is what you care about.Same can be said for hash maps, of course Python, like many other languages and libraries, provides dictionaries, therefore writing your own is useless. However if the entire point is learning how hash maps work, then perhaps writing an implementation and “having to deal with it” is not that bad.Perhaps a less accessible but more practice heavy version of this book in C would be helpful, or at least the reader should try to use a language such as a C to force himself to actually apply the knowledge that some time is purely theoretical of this book.That aside, it’s fantastic, and it’s a great first algorithm book.It made me pass my interview, allowing me to get a fairly substantial career upgrade, I can’t not suggest it.
rodrigo –
El libro llegó en excelente estado! Es excelente para adentrase en los algoritmos de programación
ZK1989 –
There are multiple serious, and sometimes very basic mistakes in Python code in this book!!! The author uses CamelCase for variables/function names, what the…?! Answers do not contain full/accurate solutions to exercises!! Book looks like totally unreviewed. Stack Overflow is full of reports on mistakes in this book!! I’m going to make a complaint to the publisher after I complete a list of mistakes. DO NOT BUY IT, IT WILL MISLEAD YOU!!!
Ugur Ardin –
Book has no damage. I have read the first 100 page. Its very informative and beginner friendly. Also its a good practice to see more examples about the topics with chatgpt, gemini or copilot