The Book of Recursion Cover

The Recursive Book of Recursion

Ace the Coding Interview with Python and JavaScript
by Al Sweigart
July 2022, 328 pp.
ISBN-13: 
9781718502024
Lay-flat binding

Look Inside!

The Recursive Book of Recursion back coverThe Recursive Book of Recursion interior spreadThe Recursive Book of Recursion interior spreadThe Recursive Book of Recursion interior spreadThe Recursive Book of Recursion interior spreadThe Recursive Book of Recursion interior spread

Download Chapter 1: WHAT IS RECURSION?

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.

Author Bio 

Al Sweigart is a software developer, fellow of the Python Software Foundation, and author of several programming books with No Starch Press, including the worldwide bestseller Automate the Boring Stuff with Python.

Table of contents 

Foreword
Acknowledgments 
Introduction

PART I: UNDERSTANDING RECURSION
Chapter 1: What Is Recursion? 
Chapter 2: Recursion vs. Iteration 
Chapter 3: Classic Recursion Algorithms 
Chapter 4: Backtracking and Tree Traversal Algorithms 
Chapter 5: Divide-and-Conquer Algorithms 
Chapter 6: Permutations and Combinations 
Chapter 7: Memoization and Dynamic Programming 
Chapter 8: Tail Call Optimization 
Chapter 9: Drawing Fractals 
PART II: PROJECTS 
Chapter 10: File Finder 
Chapter 11: Maze Generator 
Chapter 12: Sliding-Tile Solver 
Chapter 13: Fractal Art Maker 
Chapter 14: Droste Maker 
Index

Reviews 

"This book takes the mystery out of recursion. By the time you finish it, you'll see recursion as a powerful technique, but also a technique usable by mere mortals."
—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