Eduqas A-Level Computer Science A500QS
Data Structures: Arrays, Records and Hash Tables
Stacks, Queues, Linked Lists and Trees
Boolean Logic and Simplification
Algorithms, Pseudo-Code and Programming Constructs
Variables, Scope, Parameters and Identifiers
Recursion and Modular Programming
Sorting Algorithms
Searching and Shortest-Path Algorithms
Big O Notation and Algorithm Efficiency
Validation, Verification and Testing
Data Compression
Programming Paradigms and Computer Languages
Systems Analysis, Maintenance and Documentation
System Design and Human-Computer Interaction
Software Engineering Tools and Translators
Computing, Society and the Law
Computer Architecture, the Processor and Assembly Language
Input, Output and Secondary Storage
Networks, Protocols and the Internet
Data Transmission and Network Performance
Number Systems and Binary Arithmetic
Data Types, Characters and Floating Point
Files, Records and File Organisation
Databases, Normalisation and Entity Modelling
SQL, Big Data and Distributed Systems
The Operating System and Its Modes
Interrupts, Memory Management and Scheduling
Types of Software System
Data Security, Cryptography and Attack
Recursion and Modular Programming
How recursive calls use the stack
- 3 things to know
- Component 1
Overview
Call stack used for during recursion and stack frame.
What you need to know
Answer each one before you reveal it.
What is the call stack used for during recursion?
What is a stack frame?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is the call stack used for during recursion?
Model answer
The call stack holds one frame for every call that has not yet returned. Each frame stores the return address, the parameters and the local variables.
- 2
What is a stack frame?
Model answer
A stack frame is the block of memory pushed onto the stack for a single subprogram call. The frame is popped when that call returns.
- 3
Why does deep recursion risk a stack overflow?
Model answer
The stack has a fixed size and each call adds another frame. Enough unfinished calls will exhaust the space reserved for the stack.
- 4
How many stack frames exist at the deepest point of evaluating factorial(5) with base case factorial(0) = 1?
Model answer
Six frames exist at the deepest point, one each for 5, 4, 3, 2, 1 and 0. The frames are then removed one at a time as the calls return.
- 5
In what order are the recursive calls completed?
Model answer
The most recent call is completed first because the stack is last in, first out. The original call is the last to finish.
- 6
What is stored in a stack frame besides the local variables?
Model answer
The frame stores the return address and the parameters passed to that call. A saved copy of registers may also be kept.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Recursion and Modular Programming, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.