Recursion
Also known as: recursive
A technique where a function calls itself to solve progressively smaller instances of the same problem. Recursion produces elegant, concise solutions for problems with naturally self-similar structure.
💡 Intuition
Russian dolls—open one, find a smaller one inside. Repeat until you reach the smallest.
Core Idea
Every recursion needs a base case (when to stop) and a recursive case (how to continue).
🔬 Example
🎯 Why It Matters
Recursion produces elegant, concise solutions for problems with naturally self-similar structure.
⚠️ Common Confusion
Without a base case, recursion never ends—the program crashes with a stack overflow error.
Related Concepts
How Recursion Connects to Other Ideas
To understand recursion, you should first be comfortable with function and iteration.
Learn More
Common Mistakes Guides
Go Deeper
Frequently Asked Questions
What is Recursion in CS Thinking?
A technique where a function calls itself to solve progressively smaller instances of the same problem.
Why is Recursion important?
Recursion produces elegant, concise solutions for problems with naturally self-similar structure.
What do students usually get wrong about Recursion?
Without a base case, recursion never ends—the program crashes with a stack overflow error.
What should I learn before Recursion?
Before studying Recursion, you should understand: function, iteration.