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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the stack frame?

A

All the locations from the stack allocated for one subroutine call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly