Question
Draw the stack of activation records for the expression 'f 3' at the point when the recursive call 'f 1' has just been called. Explain
Draw the stack of activation records for the expression 'f 3' at the point when the recursive call 'f 1' has just been called. Explain why static activation records would fail for this function call.
f x = if x <= 0 then 5 else x + f (x-1)
Criteria for Success:
You have a diagram of three activation records. The diagram box for an activation record should contain the names and values of all the parameters and locals (in this case there are no locals). Between the records you need to draw that the dynamic links that indicate who called that activation record. You also need an explanation for why a stack is required for this problem.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started