0
0
Compiler Designknowledge~20 mins

Activation records and call stack in Compiler Design - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Activation Records Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of activation records

What is the main purpose of an activation record in the context of function calls?

ATo manage the input/output operations of a program
BTo hold the compiled machine code of a function
CTo store information about a function call such as parameters, local variables, and return address
DTo keep track of global variables across the entire program
Attempts:
2 left
💡 Hint

Think about what information a program needs to remember when it calls a function and later returns.

📋 Factual
intermediate
2:00remaining
Call stack behavior during nested function calls

Consider three functions: main calls funcA, which calls funcB. How does the call stack change during these calls?

AThe call stack replaces the activation record of <strong>main</strong> with <strong>funcA</strong>, then replaces <strong>funcA</strong> with <strong>funcB</strong>
BThe call stack remains empty until <strong>funcB</strong> is called
CThe call stack grows by adding activation records for <strong>funcB</strong>, then <strong>funcA</strong>, then <strong>main</strong>
DThe call stack grows by adding activation records for <strong>main</strong>, then <strong>funcA</strong>, then <strong>funcB</strong> in that order
Attempts:
2 left
💡 Hint

Remember that each function call adds a new activation record on top of the stack.

🔍 Analysis
advanced
2:00remaining
Identifying the return address in an activation record

Which part of an activation record is responsible for telling the program where to continue execution after a function returns?

AReturn address field
BLocal variables section
CParameter list
DSaved frame pointer
Attempts:
2 left
💡 Hint

Think about what the program needs to know to resume after finishing a function.

Comparison
advanced
2:00remaining
Difference between static and dynamic links in activation records

What is the key difference between static links and dynamic links stored in activation records?

AStatic links are used only in recursive calls, dynamic links are used in iterative calls
BStatic links point to the activation record of the lexically enclosing function, dynamic links point to the caller's activation record
CStatic links store local variables, dynamic links store parameters
DStatic links point to the caller's activation record, dynamic links point to the lexically enclosing function
Attempts:
2 left
💡 Hint

Consider the difference between lexical scope and call history.

Reasoning
expert
2:00remaining
Effect of missing dynamic link on program execution

What would most likely happen if an activation record did not store a dynamic link during a function call?

AThe program would fail to return correctly to the caller, causing incorrect execution flow or crash
BThe function would not be able to access its local variables
CThe program would run normally without any issues
DThe function parameters would be lost during the call
Attempts:
2 left
💡 Hint

Think about how the program knows where to go after a function finishes.