logo

AQA A-Level Computer Science practice

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

Try the question first, then check the answer and practise the same topic again.

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

Answer and explanation

Concise answer

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

Why this is correct

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.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions