Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 1: Draw the stack of activation records for the expression 'f 3' at the point when the recursive call 'f 1' has just been

Assignment 1:

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.

Assignment 2:

Draw the activation records for the expression 'f 3' at the point when x+z inside 'h' is being evaluated. Explain why nesting links are required and what value is returned.

f x = let h z = x + z

g x = h (x+1) in

g (x+1)

Criteria for Success:

You have a diagram of three activation records that includes both dynamic and nesting links that are clearly labeled. The nesting link indicates in which activation record the function was defined. You also need an explanation for why and how the nesting link is used.

Assignment 3:

Draw the activation records for the expression 'f 3' at the point when 'g 5' is just about to return. Explain why the activation record for 'g' can not be deallocated at that point.

f x = let g y = (\z-> z+y) in

(g 5)x

Criteria for Success:

You have a diagram of two activation records and a function object that includes the dynamic and nesting links and an explanation for why gs activation record can not be deallocated immediately after gs execution is complete.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago