Skip to main content
ICT
Lesson A9 - Recursion
 
Main   Previous Next
 

B. Pitfalls of Recursion page 4 of 8

  1. 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.

  1. 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.

Main   Previous Next
Contact
 © ICT 2006, All Rights Reserved.