Functions and the stack
On this page
This lesson contains approximately 28 minutes of video content.
Anatomy of a program in memory
Introduction to the stack
How does a function know where to find its activation record?
Some additional considerations
Questions
Q1
QFAS Q1
This question is ungraded.
The stack stores activation records (i.e., stack frames). An activation record is pushed to the stack when a function is invoked. When the function returns, its activation record is popped from the stack. Which of the following statements best describes how the stack maintains its collection of activation records?
Q2
QFAS Q2
This question is ungraded.
Which of the following is NOT stored inside a function's stack frame (i.e., activation record)?
Q3
QFAS Q3
This question is ungraded.
The following function is defined to find the nth number of the Fibonacci sequence:
int Fib(int n) {
if(n < 3)
return 1;
else
return Fib(n-1) + Fib(n-2);
}
When Fib(4) is invoked, how many times will the function Fib be called?