Tino APCS

Pitfalls of Recursion

If the recursion never reaches a base case, the recursive calls will continue until the computer runs out of memory and the program crashes. Experienced programmers try to examine the remains of a crash. The message “stack overflow error” or “heap storage exhaustion” indicates a possible runaway recursion.

When programming recursively, you need to make sure that the algorithm is moving toward a base case. Each successive call of the algorithm must be solving a version of the problem that is closer to a base case.

Last modified: December 12, 2022

Back to Recursion

Dark Mode

Outline