ITPEC FE Morning April 2021 Question 9

Which of the following explains the objective of a recursive call?

Explanation

A function using itself from within its body — that is what a recursive call is.

A recursive function solves a problem by calling itself on a smaller instance, such as n! = n × (n − 1)!, until it reaches a base case that returns without calling itself. Each call gets its own local variables and return address on the stack, so the calls unwind in reverse order.

Answer (a)

Why not others:

  • •(b) — running processes in response to events rather than in a fixed order is event-driven processing
  • •(c) — keeping a program in memory so it can run again without reloading describes a reusable program, not recursion
  • •(d) — undoing a failed process is rollback, as in transaction recovery

Key rule: A recursive routine calls itself and needs a base case to stop; it must also be reentrant, because each call keeps its own copy of the local data.

Algorithm and Programming · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.