Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Concepts of Programming Languages, 11th Edition 2. Consider the following progra

ID: 3906285 • Letter: C

Question

Concepts of Programming Languages, 11th Edition 2. Consider the following program, written in JavaScript-like syntax: // main program var x, y function aubio ( function sub20 ( var a, b, function sub30 Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last subprogram activated? Include with each visible variable the name of the unit where it is declared. a. main calls subl i subl calls sub2: subz calls sub b. main calls aubl: aubl calls sub3 C. d. calls sub3: wub3 calls sub e main calls subl : subl calls sub): sub] calls sub f. ain calls ub3b calls subz: sub2 calls sub!

Explanation / Answer

a) main : sub1 : sub2 : sub 3

   In main : Visible (x,y,z)
   In sub1 : visible (x,a,y,z) (a,y,z belong to sub1, x belong to main)
   In sub2 : visible (x,a,b,y,z) (a ,b, z belong to sub2,x belong to main, y belong to sub1)
   In sub3 : visible (x,a,w,b,y,z) (a ,x, w belong to sub3, b,z belong to sub2, y belong to sub1)

b) main : sub1 : sub3

   In main : Visible (x,y,z)
   In sub1 : visible (x,a,y,z) (a,y,z belong to sub1,x belong to main)
   In sub3 : visible (a,x,w,y,z) (a ,x, w belong to sub3 y,z belong to sub1)


c) main : sub2 : sub3 : sub 1

   In main : Visible (x,y,z)
   In sub2 : visible (x,a,b,y,z) (a ,b, z belong to sub2 | x belong to main | y belong to main)
   In sub3 : visible (a,x,w,b,y,z) (a,x,w belong to sub3 | b,z belong to sub1 | y belonh to main)
   In sub1 : visible (a,y,z,w,b,x) (a ,y, z belong to sub1 | w belong to sub3 | b belong to sub1)

d) main : sub3 : sub1

   In main : Visible (x,y,z)
   In sub3 : visible (a,x,w,y,z) (a ,x, w belong to sub3 | y,z belong to main )
   In sub1 : visible (a,y,z,x,w) (a ,y, z belong to sub1 | w,x belong to sub3 )


e) main : sub1 : sub3 : sub 2

   In main : Visible (x,y,z)
   In sub1 : visible (a,y,z,x) (a ,y, z belong to sub1 | x belong to main)
   In sub3 : visible (a,x,w,y,z) (a,x,w belong to sub3 | y,z belong to sub1)
   In sub2 : visible (a,b,z,x,w) (a ,b, z belong to sub2 | x,w belong to sub3)

f) main : sub3 : sub2 : sub 1

   In main : Visible (x,y,z)
   In sub3 : visible (a,x,w,y,z) (a ,x,w belong to sub3 | y,z belong to main)
   In sub2 : visible (a,b,z,x,w,y) (a,b,z belong to sub2 | x,w belong to sub3 | y belong to main)
   In sub1 : visible (a,y,z,x,w,b) (a ,y, z belong to sub1 | x,w belong to sub3| b belong to sub2)

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote