Book description
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.
Table of contents
- Title Page
- Copyright
- Dedication
- About the Author
- Foreword
- Acknowledgments
- Introduction
-
Part I: Understanding Recursion
- Chapter 1: What Is Recursion?
-
Chapter 2: Recursion vs. Iteration
- Calculating Factorials
- Calculating the Fibonacci Sequence
- Converting a Recursive Algorithm into an Iterative Algorithm
- Converting an Iterative Algorithm into a Recursive Algorithm
- Case Study: Calculating Exponents
- When Do You Need to Use Recursion?
- Coming Up with Recursive Algorithms
- Summary
- Further Reading
- Practice Questions
- Practice Projects
- Chapter 3: Classic Recursion Algorithms
- Chapter 4: Backtracking and Tree Traversal Algorithms
-
Chapter 5: Divide-and-Conquer Algorithms
- Binary Search: Finding a Book in an Alphabetized Bookshelf
- Quicksort: Splitting an Unsorted Pile of Books into Sorted Piles
- Merge Sort: Merging Small Piles of Playing Cards into Larger Sorted Piles
- Summing an Array of Integers
- Karatsuba Multiplication
- The Algebra Behind the Karatsuba Algorithm
- Summary
- Further Reading
- Practice Questions
- Practice Projects
-
Chapter 6: Permutations and Combinations
- The Terminology of Set Theory
- Finding All Permutations Without Repetition: A Wedding Seating Chart
- Getting Permutations with Nested Loops: A Less-Than-Ideal Approach
- Permutations with Repetition: A Password Cracker
- Getting K-Combinations with Recursion
- Get All Combinations of Balanced Parentheses
- Power Set: Finding All Subsets of a Set
- Summary
- Further Reading
- Practice Questions
- Practice Projects
- 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
Product information
- Title: The Recursive Book of Recursion
- Author(s):
- Release date: August 2022
- Publisher(s): No Starch Press
- ISBN: 9781718502024
You might also like
book
Data Structures the Fun Way
This accessible and entertaining book provides an in-depth introduction to computational thinking through the lens of …
video
Algorithms: 24-part Lecture Series
Algorithms, Deluxe Edition, Fourth Edition These Algorithms Video Lectures cover the essential information that every serious …
book
Grokking Algorithms
Grokking Algorithms is a fully illustrated, friendly guide that teaches you how to apply common algorithms …
book
Head First Design Patterns, 2nd Edition
What will you learn from this book? You know you don't want to reinvent the wheel, …