CS314, Fall 2007 Homework 5: Dynamic and Lexical Scoping Due: Thurs, Oct 18th, 2007 #1. Scott text, problem 3.9, just answer the question about how much variable storage is necessary for execution of this program. How would you manage the necessary storage during execution? #2. Scott text, problem 3.13 #3. Consider the following program in a block structured language. Program main {Var g, y; Var b=true; procedure P {Var x; Procedure R {Var y; y = Q(); g = y; /* Assign 1 */ return y; }--end R y = 2; /* Assign 2 */ x = R(); return x; }--end P procedure Q {Var y; if b then { y = 3; /* Assign 3 */ g = P(); return y; } else return 6; }--end Q y = 1; g = P(); }--end main a) Draw what the runtime stack would look like at each of the points listed below. Show the stack frames including lexical and dynamic chain links and local variables. i) The first time you reach Assign 3. ii) The second time you reach Assign 2. iii) The second time you reach Assign 1. b) Repeat the above, but use a display (as shown in class).