logo

Question detail

A subroutine calls itself recursively. Why can separate stack frames be needed for the different calls?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

A subroutine calls itself recursively. Why can separate stack frames be needed for the different calls?.

  1. A.Each call has its own return address, parameters and local variables
  2. B.Only the first call needs a stack frame; later calls share all its data
  3. C.Recursive calls do not use stack frames
  4. D.A new frame is created only when a parameter has no value

Model answer

What a good answer should say

  • Each call has its own return address, parameters and local variables

Explanation

Why this works

Each recursive call is a separate active subroutine call. Its stack frame preserves its own data and return location, so the calls can later return in the correct order.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.