Computer Science I / Recursion and Iterative Alternatives
Practice question · True or false

A recursive function that has a base case cannot recurse forever.

Hints
  1. Having a base case and reaching it are different things.
  2. What if each call moves away from the base case?
Show the answer

False

Why

False. The base case must actually be reached: f(n) calling f(n+1), or calling f(n) unchanged, recurses forever with a perfectly good base case sitting there. Termination needs a measure that strictly decreases toward the base on every call, which is the same argument as a loop variant.

Read the lesson: Recursion and Iterative Alternatives →

Practise Recursion and Iterative Alternatives

The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Recursion and Iterative Alternatives