4.1.1.15 Role of stack frames in subroutine calls Flashcards
1
Q
Why do recursive algorithms use stacks?
A
Stacks are a LIFO data structure, the last iteration of the recursion needs to return the value first, so that it returns the values in the right order.
2
Q
What is the stack frame?
A
All the locations from the stack allocated for one subroutine call.
3
Q
What could cause stack overflow?
A
If the number of recursive calls are larger than the allocated space set by the stack (the stack frame)
4
Q
What is stored within the stack frame?
A
Return addresses - where in the code the program returns to after the subroutine
Parameters of the subroutine
Local variables of the subroutine