Recursion
Solve a problem by trusting a smaller copy of itself — the base for trees, backtracking, and DP.
This topic is part of Pro.
Free covers the C and Python courses, the first three DSA topics, the opening system design lessons and the beginner AI lessons, all with the full coach. Pro opens the rest of the library in the FollowtheDamnCode app.
What is in it
- 1Thinking recursivelyA base case, a smaller subproblem, and the leap of faith that the smaller call works. Pro
- 2Call trees and what recursion costsDraw the tree of calls — its size gives the time, its height gives the space. Pro
- 3MemoizationCache each subproblem's answer the first time, and an exponential recursion becomes linear. Pro
- 4Divide and conquerSplit the problem into independent halves, solve each recursively, and combine — fast power and merge sort. Pro