1/10
AQA A-Level Computer Science
What is exception handling?
Writing code to anticipate possible errors and deal with them gracefully.
What is a subroutine?
A block of code with an identifiable, unique name within a program which breaks down a large problem.
Difference between procedure and a function.
Functions return a value.
What are advantages of suborutines?
Easier to debug
Creates reusable methods
Can be grouped in libraries for easy reuse across programs
What is a stack frame?
A frame containing information about a subroutine.
What is included within a stack frame?
Return address, local variables, subroutine parameters
What is stack overflow/underflow?
Overflow: Trying to push a stack onto a frame with no space nor memory left.
Underflow: Trying to pop off a stack from an empty frame.
Why do local variables in functions lose their values?
They are destroyed with the stack.
What is recursion?
When a subroutine calls itself from within its own subroutine.
Characteristics of recursion (3)
Contains a stopping condition (base case)
For other inputs, the program should call itself
Base case must be reachable within a finite number of loops
Why is recursion rarely used?
Consumes more memory in comparison to iterative approaches.
The processor has to recall all the return addresses.