NOTE

Recursion

Recursive problem decomposition, base cases, call-stack cost, tail recursion caveats, and iterative alternatives.

Data Structures & AlgorithmsCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

Recursion solves a problem by calling the same abstraction on a smaller/simpler state until a base case terminates the chain.

Correct recursion needs: a precise base case, progress toward it, and correct composition of sub-results. Each call consumes execution-stack state unless optimized by the runtime; many mainstream runtimes/languages do not guarantee tail-call elimination.

For unbounded/deep inputs, use an explicit stack/iterative form to avoid stack overflow.

Loading helpful count