Used - Very Good
$16.88$16.88
Ships from: bellwetherbooks Sold by: bellwetherbooks
Sorry, there was a problem.
There was an error retrieving your Wish Lists. Please try again.Sorry, there was a problem.
List unavailable.
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the author
OK
The Recursive Book of Recursion: Ace the Coding Interview with Python and JavaScript
Purchase options and add-ons
Recursion has an intimidating reputation: it’s considered to be an advanced computer science topic frequently brought up in coding interviews. But there’s nothing magical about recursion.
The Recursive Book of Recursion uses Python and JavaScript examples to teach the basics of recursion, exposing the ways that it’s often poorly taught and clarifying the fundamental principles of all recursive algorithms. You’ll learn when to use recursive functions (and, most importantly, when not to use them), how to implement the classic recursive algorithms often brought up in job interviews, and how recursive techniques can help solve countless problems involving tree traversal, combinatorics, and other tricky topics.
This project-based guide contains complete, runnable programs to help you learn:
- How recursive functions make use of the call stack, a critical data structure almost never discussed in lessons on recursion
- How the head-tail and “leap of faith” techniques can simplify writing recursive functions
- How to use recursion to write custom search scripts for your filesystem, draw fractal art, create mazes, and more
- How optimization and memoization make recursive algorithms more efficient
Al Sweigart has built a career explaining programming concepts in a fun, approachable manner. If you’ve shied away from learning recursion but want to add this technique to your programming toolkit, or if you’re racing to prepare for your next job interview, this book is for you.
- ISBN-101718502028
- ISBN-13978-1718502024
- PublisherNo Starch Press
- Publication dateAugust 16, 2022
- LanguageEnglish
- Dimensions7.01 x 0.75 x 9.25 inches
- Print length328 pages
Frequently bought together

Deals on related products
Customers also bought or read
- Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples
Paperback$30.99$30.99Delivery Sun, May 10 - Dive Into Algorithms: A Pythonic Adventure for the Intrepid Beginner
Paperback$34.91$34.91Delivery Sun, May 10 - Object-Oriented Python: Master OOP by Building Games and GUIs
Paperback$35.64$35.64FREE delivery May 15 - 17 - Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code
Paperback$19.55$19.55Delivery Sun, May 10 - Algorithmic Thinking, 2nd Edition: Learn Algorithms to Level Up Your Coding Skills
Paperback$32.49$32.49Delivery Sun, May 10 - Think Like a Programmer: An Introduction to Creative Problem Solving
Paperback$23.63$23.63Delivery Sun, May 10 - Modeling and Simulation in Python: An Introduction for Scientists and Engineers
Paperback$30.63$30.63$3.99 delivery Wed, May 20 - Impractical Python Projects: Playful Programming Activities to Make You Smarter
Paperback$21.17$21.17Delivery May 14 - 18 - The Big Book of Small Python Projects: 81 Easy Practice Programs
Paperback$31.99$31.99Delivery Sun, May 10 - Practical SQL, 2nd Edition: A Beginner's Guide to Storytelling with Data
Paperback$21.49$21.49Delivery Sun, May 10 - Graph Algorithms the Fun Way: Powerful Algorithms Decoded, Not Oversimplified
Paperback$33.25$33.25Delivery Sun, May 10 - Math for Deep Learning: What You Need to Know to Understand Neural Networks
Paperback$35.68$35.68FREE delivery Sun, May 10 - Grokking Algorithms, Second Edition: An illustrated guide for programmers and other curious people
Paperback$39.70$39.70FREE delivery Sun, May 10 - How Cybersecurity Really Works: A Hands-On Guide for Total Beginners
Paperback$23.08$23.08Delivery Sun, May 10 - Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, and More!
Paperback$29.36$29.36Delivery May 13 - 15 - Learn to Code by Solving Problems: A Python Programming Primer
Paperback$23.40$23.40Delivery May 13 - 15 - Python Crash Course, 3rd Edition: A Hands-On, Project-Based Introduction to Programming#1 Best SellerIntroductory & Beginning Programming
Paperback$27.53$27.53Delivery Sun, May 10 - Serious Python: Black-Belt Advice on Deployment, Scalability, Testing, and More
Paperback$25.00$25.00Delivery Sun, May 10 - Fluent Python: Clear, Concise, and Effective Programming
Paperback$43.99$43.99FREE delivery Sun, May 10 - Coding Interview Patterns: Nail Your Next Coding Interview#1 Best SellerMathematical & Statistical Software
Paperback$40.00$40.00FREE delivery Sun, May 10 - The Secret Life of Programs: Understand Computers -- Craft Better Code
Paperback$30.15$30.15$3.99 delivery Thu, May 21 - The Algorithm Design Manual (Texts in Computer Science)
Hardcover$56.44$56.44FREE delivery Sun, May 10 - Dead Simple Python: Idiomatic Python for the Impatient Programmer
Paperback$45.02$45.02FREE delivery Sun, May 10 - How Computers Really Work: A Hands-On Guide to the Inner Workings of the Machine
Paperback$27.81$27.81$3.95 delivery May 27 - Jun 1 - Write Great Code, Volume 1, 2nd Edition: Understanding the Machine
Paperback$32.49$32.49$3.99 delivery Thu, May 21 - Code: The Hidden Language of Computer Hardware and Software
Paperback$31.95$31.95Delivery Sun, May 10 - 50 Algorithms Every Programmer Should Know: Tackle computer science challenges with classic to modern algorithms in machine learning, software design, data systems, and cryptography
Paperback$35.55$35.55FREE delivery Sun, May 10
Editorial Reviews
Review
—John D. Cook
"... this book is a worthy read for a developer who wants to deepen their knowledge of advanced programming topics. While basic recursion is included in early programming curriculum, it typically stops at examples that can be reproduced with iteration. In this book, Al Sweigart starts are these basics and quickly expands to include types of algorithms that benefit from recursion, such as tree traversal and divide-and-conquer. Though focused on those actively interviewing for engineering roles, the book is also a good fit for professional development, an engineering book club, or a brain tickler for your technical book shelf. The real life projects at the end are especially informative, which is why I think... (this review 'recurs' to the beginning)"
—Adam DuVander, @adamd, Founder of EveryDeveloper
"I have felt for a long time that I had a pretty good handle on the subject of recursion . . . Thanks to Al Sweigart's new book, I think I'm far better informed than I was before. I will re-read this book a couple more times, just to add to the knowledge."
—Ronnie Tucker, Editor, Full Circle Magazine
About the Author
Product details
- Publisher : No Starch Press
- Publication date : August 16, 2022
- Language : English
- Print length : 328 pages
- ISBN-10 : 1718502028
- ISBN-13 : 978-1718502024
- Item Weight : 1.35 pounds
- Dimensions : 7.01 x 0.75 x 9.25 inches
- Best Sellers Rank: #243,779 in Books (See Top 100 in Books)
- #16 in JavaScript Programming (Books)
- #98 in Computer Programming Languages
- #119 in Python Programming
- Customer Reviews:
About the author

Al Sweigart is a software developer and tech book author living in Houston. He has written several programming books for beginners, including Automate the Boring Stuff with Python. His books are freely available under a Creative Commons license at his website https://inventwithpython.com.
Related products with free delivery on eligible orders
Customer reviews
- 5 star4 star3 star2 star1 star4 star95%0%0%5%0%0%
- 5 star4 star3 star2 star1 star3 star95%0%0%5%0%0%
- 5 star4 star3 star2 star1 star1 star95%0%0%5%0%0%
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonReviews with images
A must to have book which can make a good developer a great developer.
Top reviews from the United States
- 5 out of 5 stars
As good as Al's other books; great!
Reviewed in the United States on December 22, 2024Many others have already said wonderful things about this book, and I wholeheartedly agree with them. As a Ph.D. in Applied Mathematics and Statistics, I find myself in an unusual position: despite the growing necessity of coding in modern research and experimentation, I simply don’t enjoy it. While I believe I have the capacity to code, it has never been something I truly liked. That’s why Al’s books have been a revelation for me. Al is a great educator. He has a talent of teaching programming in a way that resonates. It truly got me intrigued. I’ve purchased several of his books to show my gratitude.
3 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Clear and Practical Approach to Learning Recursion
Reviewed in the United States on January 30, 2026The Recursive Book of Recursion teaches recursion in a clear, methodical way that actually helps you understand how it works, rather than just showing patterns to memorize. The explanations build gradually, making complex ideas feel approachable instead of abstract or intimidating.
The Python and JavaScript examples are well designed and reinforce the underlying concepts, helping you develop the right mental model for recursive thinking. The exercises are meaningful and encourage real understanding, not trial-and-error coding.
Overall, this is a well-structured, thoughtful book for anyone who wants to genuinely learn recursion and feel confident applying it in real code. Highly recommended for developers who want a deeper, clearer grasp of this topic.
One person found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
A Deep Introduction to Recursion in Programming with Examples in Python and JavaScript
Reviewed in the United States on September 7, 2022I encourage folks learning programming to first buy Al Sweigart’s book, “Automate the Boring Stuff with Python”. That book teaches you Python from the beginning and assumes no previous knowledge. The book used in conjunction with his video course on Udemy, similarly named “Automate the Boring Stuff with Python”, are a great way to start learning Python.
His latest book, "The Recursive Book of Recursion", takes the reader into the more advanced subject of recursion. Topics include the concepts of the stack, pushing in and popping out of the stack, and stack overflow. Recursion is compared to iteration, and examples are shown where both approaches are shown and critiqued. Cases where recursion is advantageous are presented with illustrations to enhance one’s comprehension. While not a beginner’s book, it is a good read to fill in a sufficiently complex subject. Copious Python and JavaScript recursion code are provided. Some fun and cool demonstrations of recursion make use of turtle graphics. Going forward, this will be my ‘go-to’ reference for recursion. Thank you, Al Sweigart!
Here’s a breakdown of what’s included (from the book):
Introduction - Covers how to set up Python and JavaScript on your computer to follow along with the code examples in the rest of the book.
Part 1: Understanding Recursion
Chapter 1: What is Recursion? - Explains recursion and how it is the natural result of the way programming languages implement functions and function calls. This chapter also argues that recursion isn’t nearly the elegant, mystical concept many claim it is.
Chapter 2: Recursion vs. Iteration – Dives into the differences (and many similarities) between recursive and iterative techniques.
Chapter 3: Classic Recursion Algorithms – Covers famous recursive programs such as the Tower of Hanoi, the flood fill algorithm, and others.
Chapter 4: Backtracking and Tree Traversal Algorithms – Discusses a problem for which recursion is particularly suited: traversing tree data structures, such as when solving mazes and navigating a directory.
Chapter 5: Divide-and-Conquer Algorithms – Discusses how recursion is useful for splitting large problems into smaller subproblems and covers several common divide-and-conquer algorithms.
Chapter 6: Permutations and Combinations – Covers recursive algorithms involving ordering and matching, as well as the common programming problems to which these techniques are applied.
Chapter 7: Memoization and Dynamic Programming – Explains some simple tricks to improve code efficiency when applying recursion in the real world.
Chapter 8: Tail Call Optimization – Covers tail call optimization, a common technique used to improve the performance of recursive algorithms, and how it works.
Chapter 9: Drawing Fractals – Tours the intriguing art that can be programmatically produced by recursive algorithms. This chapter makes use of turtle graphics for generating its images.
Part 2: Projects
Chapter 10: File Finder – Covers a project that searches through the files on your computer according to custom search parameters you provide.
Chapter 11: Maze Generator – Covers a project that automatically generates mazes of any size using the recursive backtracker algorithm.
Chapter 12: Sliding-Tile Solver – Covers a project that solves sliding-tile puzzles, also called 15-puzzles.
Chapter 13: Fractal Art Maker – Explore a project that can produce custom fractal art of your own design.
Chapter 14: Droste Maker – Explores a project that produces recursive, picture-in-picture images using the Pillow image-manipulation module
Finally, I would also recommend another one of his earlier books, “Cracking Codes with Python”. This is an excellent book on using Python to encrypt, decrypt, and cracking various encryption algorithms.
5 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Recursion With a Dose of Encouragement
Reviewed in the United States on November 19, 2022It may seem odd that a book devoted entirely to recursion would contain such statements as “You never need to use recursion. No programming problem requires recursion … In fact, a recursive function might be an overcomplicated solution…” Nevertheless, Al Sweigert goes on to explain the ins and outs of a programming technique you should rarely, if ever, need to use. And he does so masterfully.
Recursion and recursive functions seem to many (including me) to be esoteric mysteries, understandable only to those elite few who are wired to think in a pretty unconventional way. We are taught from a young age that you can’t define a word by using that word, itself. To that idea, recursion says “watch me!”.
In explaining recursion, Sweigert is careful to begin by laying important groundwork. With adequately (but not overly) detailed and approachable explanations and examples, he discusses functions, their operation and features. He spends significant time explaining the call stack, what it does, how it is structured, and how it operates, leading to a discussion of ‘stack overflow’, one of the risks of using recursion. With that out of the way, he then devotes an entire chapter to comparing recursion and iteration, demonstrating that in the vast majority of cases, recursive functions simply aren’t necessary and in some cases perform worse than their iterative counterparts.
The ensuing chapters look at recursion in action, exploring several popular recursive algorithms and techniques. It is in these chapters where we begin to see where recursion is actually a good idea, where it is a good fit (and also where it is not). So, while recursion may be mostly unnecessary, it is absolutely tailor-made for certain functions. Among other things, Sweigert explores traversing tree structures and demonstrates how memoization (yes, I spelled that correctly) can improve the efficiency of some recursive functions. He provides a plethora of examples demonstrating each concept he explores. It is worth noting here that Sweigert provides code examples in both Python and JavaScript (where possible), making it a valuable resource for students of both. The book ends with several projects that build on the lessons that come before, including one that implements the very cool Droste Effect.
For the beginning and intermediate programmer, which is the only demographic to which I can relate, the real value of this book lies not only in its teaching about recursion. Its value also stems from its ability to stretch you just a little bit further, to make think just a little bit differently, to give you confidence that maybe lofty concepts that seem way above your head are within reach. Any book that can achieve that while simultaneously telling you that what you’re learning is mostly unnecessary is well worth the read.
--Reviewer was provided a review copy by the author
11 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Compassionate, Clear, and Straightforward
Reviewed in the United States on September 29, 2022I've enjoyed Al's books in the past, and I'm so glad I checked this one out too. I appreciate the structure, the tone, and the examples in this book the most.
So far, the book is compassionate in its approach to a subject that many learners find intimidating, and is quick to acknowledge when and, more importantly, WHY things might be confusing (e.g. it references "The fact that the call stack doesn't exist in source code is the main reason recursion is so confusing to beginners: recursion relies on something the programmer can't even see!") This type of explanation and acknowledgment help new learners feel at ease.
This book also has great examples in the form of both code (JavaScript and Python) and diagrams/figures. First, the text describes what is happening in an example, then you get to see the code, and then often a diagram or table that visually demonstrates exactly what is happening in the example.
I also appreciate the simplicity of some the examples in the first few Chapters. The book uses common examples (Fibonacci, factorial, exponents, palindromes...) that students likely have already seen (non-recursively) in previous exposures to educational programming content. As someone who doesn't actively think about recursion day-to-day, I appreciate these examples that I can easily wrap my head around.
I also appreciate the "Further Reading" sections, which point readers to deeper or alternative sources covering the relevant material!
All in all, this is another book from Al that I think people should check out if they want to dig deeper into recursion!
4 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
A must to have book which can make a good developer a great developer.
Reviewed in the United States on January 15, 2023Recursion is a complex topic to understand in the first place no matter which language we chose to pick to implement the concepts. In this book, Al starts with the intuition of what is recursion via multiple examples, and gradually moved towards defining many condepts like functions, stacks, call stack and so on. I loved the second chapter on Recursion vs Iteration which build a foundation on taking the decision on when to use recursion and when not to. I would strongly recommend to go over chapter 1 to chapter 3 even if you are well verged with recursion/DP, this 3 chapters has lot to offer for anyone who is new as well as for seasoned developer.
The best chapter for me was on memorization and DP, I loved the vizual images used by Al on explaning few of recursive function calls.
Its a must have book for any software engineer who is looking to build a very strong foundation on recursion and DP. And this book also can help to strengthen many general computer science concepts. I would highly recommend this book and would advice to code as you read the book and dont jump to the next chapter without practicing.
Lastly, I just wish the publisher make a colored version of this book, I guess it would enhance the learning if we have the book in colored version (it really helps to reach the code snip-it and images)

5 out of 5 starsA must to have book which can make a good developer a great developer.
Reviewed in the United States on January 15, 2023Recursion is a complex topic to understand in the first place no matter which language we chose to pick to implement the concepts. In this book, Al starts with the intuition of what is recursion via multiple examples, and gradually moved towards defining many condepts like functions, stacks, call stack and so on. I loved the second chapter on Recursion vs Iteration which build a foundation on taking the decision on when to use recursion and when not to. I would strongly recommend to go over chapter 1 to chapter 3 even if you are well verged with recursion/DP, this 3 chapters has lot to offer for anyone who is new as well as for seasoned developer.
The best chapter for me was on memorization and DP, I loved the vizual images used by Al on explaning few of recursive function calls.
Its a must have book for any software engineer who is looking to build a very strong foundation on recursion and DP. And this book also can help to strengthen many general computer science concepts. I would highly recommend this book and would advice to code as you read the book and dont jump to the next chapter without practicing.
Lastly, I just wish the publisher make a colored version of this book, I guess it would enhance the learning if we have the book in colored version (it really helps to reach the code snip-it and images)
2 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Recursion Demystified
Reviewed in the United States on September 13, 2022I thoroughly enjoyed working through the code samples accompanied by Al's clear and understandable explanations. There are gems of advice sprinkled throughout the entire book.
The first couple of chapters provides a very clear explanation of recursion and a good comparison of recursion vs. iteration. Understanding is furthered by knowing any recursive algorithm can be performed iteratively using a loop and a stack. Guidance is provided about when and when not to use recursion, and what three features of a programming problem, when present, make it especially suitable to a recursive approach.
Three key questions are answered for each recursive code sample: What is the base case? What argument is passed to the recursive function call? How does this argument become closer to the base case?
Other parts I thoroughly enjoyed:
- Seeing how a perfect maze can be represented by graph (DAG)
- Quicksort walk-through (Perhaps the best explanation I've ever seen of this classic algorithm.)
- Karatsuba Multiplication algorithm and also the supporting math
- Introductory set theory refresher
- What it means for a function to be "pure"
- Memoization and why only pure functions should be memoized
- How tail call optimization works
Larger projects follow that provide more opportunities to work through code and see how recursion can be used to succinctly and elegantly implement solutions. I had fun playing with the Sliding-Tile Solver.
4 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
An Excellent Book that is Excellent
Reviewed in the United States on September 4, 2022As a full-stack developer in the LIS (Library and Information Science) field, Al's work has always been an important cornerstone in my coding education. Data and Systems librarians are often self-taught, and I am no exception. "Automate the Boring Stuff with Python" was my Bible as I took my first steps into the field and I always recommend it to anyone who wants to follow in similar footsteps.
This new title has its own place in my journey: demystifying recursion - a concept that is largely glossed over in any coding classes or bootcamps. Al handles this task with ease, thoroughly covering the gamut with his trademark accessible language, clear examples, and concise writing. For real, there's no fat to trim in this title! The result is a surprisingly easy and enjoyable read; I recommend it to anyone who wants to clear up the mystery of recursion for themselves. Don't worry about getting lost in the sauce; if you know the basics of Python or JavaScript, you'll have no problem following along.
Note: I am writing this review based on a review copy provided by the author. That said, I am purchasing a copy for myself because I enjoyed it so much.
2 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Top reviews from other countries
Smart Aleck5 out of 5 starsÇok güzel bir kitap.Tavsiye ederim.
Reviewed in Turkey on February 7, 2024Kitap bu konuda çok işime yaradı. Konu ile ilgililere şiddetle tavsiye ederim. Faydalı bir kitap akıcı ve anlaşılır. Pek çok şey öğreniyorsunuz. Tabi konu ile ilgili biriyseniz. Python ve Javascript programlama dillerinde intermediate seviyede birikiminiz olması gerektiğini önemle belirteyim. Intermediate seviyedeyseniz alın işe yarar. Baskısı gayet kaliteli ve rahat okunabilir punto büyüklüğü. Ucuza alacağım diye gidip fotokopi, fake kitaplara para vermeyin tavsiye etmem.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Ricardo D5 out of 5 starsTo understand recursion, one must first understand recursion.
Reviewed in Australia on May 7, 2023This book does a good job of it...
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Vladimir Nabokov5 out of 5 starsGood insight
Reviewed in the United Kingdom on June 19, 2024I bought this book as a companion to Elements of Programming Interviews in Python. Glad I did as it has helped my understanding of recursion a lot.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
J. Bachmann5 out of 5 starslesenswertes Buch
Reviewed in Germany on November 5, 2025Sehr gutes Buch, um Rekursion zu lernen wirklich lesenswert. Großartiger Autor.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Loki20185 out of 5 starsTop
Reviewed in Germany on February 14, 2023Erfüllt seinen Zweck
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again














