Tue 09 August 2022

New Book: The Recursive Book of Recursion by Al Sweigart

Posted by Al Sweigart in misc   

article header image

Book cover of The Recursive Book of Recursion with caption 'New book'

My new programming book, the Recursive Book of Recursion, is released in August 2022. The book covers several classic recursive algorithms and breaks down recursion's fearsome reputation as a programming technique. The book has the code for its numerous programs in both Python and JavaScript. When you buy it direct from the publisher, No Starch Press, you'll receive a DRM-free ebook copy with your print book order.

Here's the contents 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.

Diagram showing a stack falling over. Cpation reads Figure 1-8: A stack overflow happens when the call stack becomes too high, with too many frame objects taking up the computer's memory.

Chapter 2: Recursion vs. Iteration - Dives into the differences (and many similarities) between recursive and iterative techniques.

A diagram of a maze's hallways morphing into tree branches. Caption reads Figure 2-5: A maze (left) along with its interior paths (center) morphed to match a biological tree's shape (right).

Chapter 3: Classic Recursion Algorithms - Covers famous recursive programs such as the Tower of Hanoi, the flood fill algorithm, and others.

Photo of a wooden Tower of Hanoi game, with three pegs. One peg has six discs with holes in their centers stacked, with wider discs on the bottom.

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.

Four pictures of tree graphs. The left is a tree. The next one is not a tree because one node has multiple parents. The next one is not a tree because a child node loops back to an ancestor node. The next one is not a tree because there are multiple root nodes. Caption reads Figure 4-1: A tree (left) and three examples of non-trees (middle and right).

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.

Drawing of a stack of books being split into two stacks, which are split into four stacks. Caption reads: Figure 5-2: Quicksort works by repeatedly partitioning items into two sets.

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.

Diagram of six different wedding tables with every possible ordering of three wedding guests.

Chapter 7: Memoization and Dynamic Programming - Explains some simple tricks to improve code efficiency when applying recursion in the real world.

Caption reads: Figure 7-1: A tree diagram of the recursive function calls made starting with fibonacci(6). The redundant function calls are in gray.

Chapter 8: Tail Call Optimization - Covers tail call optimization, a common technique used to improve the performance of recursive algorithms, and how it works.

Caption reads Figure 8-1: The process of transformations that factorial(5) makes to the integer 120.

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 - Explores 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.


Check out other books by Al Sweigart, free online or available for purchase:

...and other books as well! Or register for the online video course. You can also donate to or support the author directly.