Question: Consider the following pseudocode, assuming nested subroutines and static scope: (a) What does this program print? (b) Show the frames on the stack when A
Consider the following pseudocode, assuming nested subroutines and static scope:
(a) What does this program print?

(b) Show the frames on the stack when A has just been called. For each frame, show the static and dynamic links.
(c) Explain how A finds g.
procedure main() g: integer procedure Bla : integer) x: integer procedure Aln : integer) g:=n procedure R(m : integer) write integer(x) x/:= 2 -- integer division if x > 1 RIm + 1) else Alm) -- body of B X:= a x a R(1) -- body of main B(3) writeinteger(g)
Step by Step Solution
3.54 Rating (164 Votes )
There are 3 Steps involved in it
a 9 4 2 3 b c It dereferences its static link to find the stack frame of ... View full answer
Get step-by-step solutions from verified subject matter experts
