Podcast thumbnail

Grokking Artificial Intelligence Algorithms

14 min
4.8

Introduction

Nova: Welcome back, everyone. Today we're diving into a book that uses ant colonies, bird flocks, and even Connect Four to teach you how artificial intelligence actually works. It's called Grokking AI Algorithms by Rishal Hurbans, now in a brand new second edition.

Nova: That's exactly the point. This book is part of Manning's Grokking series, and the whole philosophy is that you don't need a PhD in mathematics to understand how AI algorithms work. Hurbans uses illustrations, hands-on Python exercises, and jargon-free explanations to build intuition first and theory second.

Nova: That's the million-dollar question, and honestly, the reviews suggest this book threads the needle brilliantly. One reviewer said it takes an impossibly broad area of computer science and communicates what working developers need to understand in a clear and thorough way. Another said it removes the fear of stepping into the mechanics of AI. And the second edition, published this year, now includes two brand-new chapters on large language models and generative image models. So you literally build a tiny LLM from scratch.

Nova: Not exactly ChatGPT, but you'll build the pipeline that makes next-word prediction work. By the end, you'll grok what's happening under the hood, not just parrot buzzwords. And that's what makes this book different. Let's dig in.

Why Visual Learning Wins

The Grokking Philosophy

Nova: So before we tour the algorithms themselves, let's talk about why this book exists and who Rishal Hurbans is. He's a technologist and serial entrepreneur from South Africa who spent over a decade building tech solutions across finance, health, agriculture, mining, and aviation. He noticed a pattern: brilliant developers kept hitting a wall with AI, not because they weren't smart enough, but because the learning materials were impenetrable.

Nova: Exactly. Hurbans' core belief is that technology should amplify human potential, and that means making complex ideas accessible. So he wrote a book where every concept has a visual anchor. Search algorithms are drawn as mazes with little stick figures exploring paths. Neural networks are shown as connected circles lighting up. Evolutionary algorithms are illustrated as creatures mutating across generations.

Nova: It's from Robert Heinlein's sci-fi novel Stranger in a Strange Land. To grok something means to understand it so deeply that it becomes part of you. Not memorizing, not parroting, but truly internalizing. That's the ambition here.

Nova: Right. And the way it does that is by showing you the algorithm thinking through a problem visually before you ever see code. Each chapter opens with a relatable problem, walks through how a human might solve it, then shows how the AI algorithm mirrors or improves on that thinking. Only then do you get the Python implementation.

Nova: Precisely. And Hurbans is methodical about this. The preface of the book actually traces the history of human automation, from early tools through the industrial revolution to modern AI, making the case that algorithms are just the latest chapter in humanity's long desire to solve hard problems with less effort.

Nova: Yes. And he doesn't shy away from ethics either. One reviewer specifically praised the ethics discussion as the icing on the cake. The book encourages readers to think about responsible decision-making when deploying AI. It's not just how to build, but whether and why to build.

The Twelve-Chapter Journey

From Ant Colonies to Neural Networks

Nova: Let's walk through the actual structure of the book. Twelve chapters, each building on the last, moving from classic AI to cutting-edge generative models.

Nova: Chapter one is all about the intuition of artificial intelligence. What does intelligence even mean in a computational context? Why is data the fuel? How do algorithms act like recipes? It sets the philosophical and conceptual stage before any code is written.

Nova: Then chapters two and three dive into search, which Hurbans calls the foundation of modern AI. You start with uninformed search. Breadth-first search and depth-first search. Imagine you're in a maze. BFS explores every path level by level, wide before deep. DFS picks a path and goes as far as it can before backtracking.

Nova: Great analogy. Then chapter three introduces intelligent search with heuristics, rules of thumb that guide the search. This is where A-star comes in, the algorithm that powers everything from GPS navigation to video game pathfinding. And then adversarial search with the minimax algorithm, which you apply by building a Connect Four AI opponent.

Nova: Yes. Chapters four and five tackle evolutionary algorithms. The big idea here is you borrow concepts from biological evolution: variation, selection, and mutation. You encode candidate solutions, measure their fitness, select the best parents, and breed new generations. The book walks you through the classic knapsack problem. You have a limited-capacity backpack and items with different values and weights. Which combination maximizes value?

Nova: Exactly. And chapter five extends this with alternative encodings: real numbers, ordered sequences, and tree structures. Different problems demand different representations.

Nova: Chapters six and seven. Swarm intelligence. Ant colony optimization is chapter six. Real ants leave pheromone trails. Over time, the shortest path to food gets the strongest pheromone concentration because ants traverse it more frequently. The algorithm mimics this to solve routing and network optimization problems.

Nova: It really is. Then chapter seven is particle swarm optimization, inspired by bird flocking. Each particle has a position and velocity. It's pulled toward its own best-known position and the swarm's global best, balancing individual exploration with social learning. The book's example is optimizing a drone's material composition, balancing aluminum and plastic for the best weight-to-strength ratio.

Nova: Chapter eight is machine learning fundamentals, including linear regression on diamond pricing data and classification with decision trees. Chapter nine is artificial neural networks, starting with the humble perceptron and building up to forward propagation, backpropagation, and activation functions. The example predicts accidents from driving conditions.

Nova: Chapter ten. Q-learning. The example is genuinely fun: you train an agent to park a car in a crowded parking lot. The agent explores, tries random actions, gets rewards for good parking and penalties for collisions, and gradually builds a Q-table that encodes the best action for every state.

Nova: That's essentially what it is. And then the big additions in the second edition: chapter eleven on large language models and chapter twelve on generative image models. You build a tiny LLM pipeline, learning about embeddings, self-attention, and next-word prediction. And for images, you explore diffusion models, understanding how iterative denoising reveals structure inside random noise.

Projects That Make It Real

Learning by Building

Nova: Let's zoom in on the projects because they're really the heart of why this book works. Every algorithm is paired with a coding exercise you can actually run. The GitHub repository has all the Python code, and the second edition added PyTorch support for the deep learning chapters.

Nova: A maze solver using A-star search. You define a grid with walls, a start point, and a goal. The algorithm uses a heuristic, typically Manhattan distance, to estimate how far each cell is from the goal. It prioritizes exploring cells that minimize the sum of the path taken so far plus the estimated remaining distance.

Nova: Exactly. And you can watch it in action. Then you build the Connect Four AI with minimax. The AI looks several moves ahead, building a game tree of possible moves and counter-moves, then picks the path that maximizes its chance of winning even if the opponent plays perfectly.

Nova: Same principle. Then the genetic algorithm for the knapsack problem. You encode potential solutions as binary strings where each bit represents whether an item is included. You calculate fitness as total value, penalizing solutions that exceed the weight limit. Then you select parents using tournament selection, perform crossover to combine their traits, and occasionally mutate a bit. Over dozens of generations, the population converges on near-optimal solutions.

Nova: Great question. The book covers parameter configuration: population size, mutation rate, crossover rate, and termination conditions. Too much mutation and you never converge. Too little and you get stuck in local optima. It's a balance.

Nova: That's particle swarm optimization. You're designing a drone frame. You need to balance aluminum, which is lightweight but expensive, against plastic, which is cheaper but heavier. Each particle in the swarm represents a different ratio. They fly through the solution space, influenced by their own best discovery and the swarm's collective best. Eventually they converge on the optimal material mix.

Nova: That's intentional. Hurbans is drawing from his industry experience. He's built solutions in mining, aviation, agriculture. These examples mirror real-world optimization challenges.

Nova: Yes. You feed in driving conditions: weather, time of day, road type, speed. The network learns to predict accident likelihood. You build it layer by layer, implement forward propagation to make predictions, then backpropagation to adjust weights based on prediction errors. By the end, you understand why deep learning works, not just that it works.

Nova: Same. You start with bigrams, building probability tables from sample text. Then you learn about tokenization and embeddings, converting words into vectors that capture semantic meaning. Then self-attention, where the model learns which words in a sentence are related to which others. You literally train a tiny model and watch next-word predictions emerge.

Nova: Exactly. And the image generation chapter uses the sculptor analogy: diffusion models start with random noise and iteratively remove noise to reveal an image, like a sculptor chipping away at marble to reveal a statue. You control the process with a text prompt that guides the denoising toward what you described.

The Bigger Picture

Why This Book Matters Now

Nova: Let's step back and ask the big question: in a world overflowing with AI content, why does this particular book stand out?

Nova: A few things. First, curation. The internet is a firehose of fragmented information. This book gives you a structured, progressive journey. You don't jump from regression to transformers with no connective tissue. Each chapter builds on the last, and Hurbans explicitly shows the conceptual through-lines.

Nova: Exactly. Second, the visual approach genuinely reduces cognitive load. Research shows that dual coding, combining verbal and visual information, improves comprehension and retention. When you see an ant colony diagram next to pseudocode for ACO, your brain encodes the concept twice, making it stickier.

Nova: Third, the second edition additions are genuinely timely. The first edition came out in 2020 before ChatGPT and Stable Diffusion exploded into public consciousness. The new chapters on LLMs and generative image models mean the book now covers the algorithms everyone is actually talking about right now.

Nova: It's aimed at software developers who want to build AI-powered features but have never formally studied AI. If you already have a PhD in machine learning, you'll find chapters one through seven too introductory. But even experienced practitioners might find the visual approach refreshing and the LLM and diffusion model chapters valuable as a conceptual on-ramp.

Nova: Beginning to intermediate programming skills and high school mathematics. The book explicitly says no AI experience required. You should know Python basics and be comfortable with variables, functions, and loops. But you don't need calculus or linear algebra.

Nova: That's the point. Hurbans is trying to democratize AI understanding. He wants the front-end developer who's curious about machine learning to have a path in. He wants the product manager who needs to talk intelligently with engineers to have a shared vocabulary.

Nova: Yes, and that's one of its quietly radical features. The preface discusses humanity's long relationship with automation and the responsibility that comes with building intelligent systems. Throughout the book, Hurbans returns to questions of bias, fairness, and unintended consequences. It's not a separate ethics chapter tacked on at the end. It's woven into the fabric.

Nova: One reviewer, Gandhirajan Natarajan from Dell EMC, specifically called out the ethics discussion as the icing on the cake. And I think that says something. When even enterprise technologists are praising a beginner book for its ethical depth, the author is doing something right.

Conclusion

Nova: Let's bring it all together. Grokking AI Algorithms by Rishal Hurbans is a visually rich, project-driven guide that takes you from first principles of search all the way to building your own miniature large language model and image diffusion pipeline.

Nova: And it does it without drowning you in notation. The secret weapon is the visual approach. Every algorithm is drawn before it's coded. Every concept has a real-world analogy. Every chapter ends with a project you can run and modify. It's built for understanding, not for impressing academic reviewers.

Nova: Exactly. Think of it as the difference between learning to drive by studying an engine manual versus actually getting behind the wheel with an instructor. The manual has its place, but most people learn better by doing. Hurbans puts you in the driver's seat from chapter one.

Nova: Here's my takeaway for listeners. If you're a software developer who's been side-eyeing the AI revolution, feeling like you missed the boat, this book is your boarding pass. It won't make you an AI researcher overnight. But it will give you the conceptual fluency to read papers, understand architectures, and build your own experiments. It replaces fear with curiosity.

Nova: Couldn't agree more. So whether you're building the next great AI product or just trying to understand what your engineering team is talking about at standup, Grokking AI Algorithms deserves a spot on your shelf, or more likely, open on your desk next to your code editor.

Nova: Thank you, Ash. And to our listeners, if this episode sparked your curiosity, grab a copy of the book, clone the GitHub repo, and start building. The algorithms are waiting.

Nova: This is Aibrary. Congratulations on your growth!

00:00/00:00