Ch 8 · Recursion — Functions That Call Themselves · Data Structures & Algorithms
Topic 8 of 10 in Data Structures & Algorithms — Foundations — 2 lessons.
Base Case + Recursive Case
Recursion is when a function calls itself on a smaller version of the problem. Every recursion needs two parts: a base case that stops it, and a recursive case that shrinks the problem toward that base.
When Recursion Gets Expensive
Recursion is elegant but can repeat the same work enormously. Naive Fibonacci recomputes the same values again and again — exponential time. Memoising (remembering results) collapses it to O(n).
All topics in Data Structures & Algorithms Beginner
- Thinking Like a Computer Scientist
- Arrays & Lists — The Workhorse
- Stacks — Last In, First Out
- Queues — First In, First Out
- Linked Lists — Nodes on a Chain
- Searching — Finding the Needle
- Sorting — Putting Things in Order
- Recursion — Functions That Call Themselves
- Hash Tables — Instant Lookups
- Mini-Projects & Practice