GATE | GATE CS 2012 | Question 34
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
Program main;
Var ...
Procedure A1;
Var ...
Call A2;
End A1
Procedure A2;
Var ...
Procedure A21;
Var ...
Call A1;
End A21
Call A21;
End A21
Call A1;
End main.
Consider the calling chain : Main->A1->A2->A21->A1
The correct set of activation records along with their access links is given by :

(A) A
(B) B
(C) C
(D) D
Answer: (D)
Explanation: Access link is defined as link to activation record of closest lexically enclosing block in program text, so the closest enclosing blocks respectively for A1 ,A2 and A21 are main , main and A2 Since, Activation records are created at procedure entry time and destroyed at procedure exit time.
Solution:
Link to activation record of closest lexically enclosing block in program text. It depends on the static program text.
Here Calling sequence is given as,
Main->A1->A2->A21->A1
Now A1,A2 are defined under Main…So A1,A2 Access link are pointed to main A21 is defined under A2 hence its Access link will point to A2 .
Reference:
http://www.cs.nyu.edu/courses/spring08/G22.2130-001/lectures/lecture-13.html
This solution is contributed by Nitika Bansal
Recommended Posts:
- GATE | GATE CS 2012 | Question 25
- GATE | GATE CS 2012 | Question 14
- GATE | GATE CS 2012 | Question 65
- GATE | GATE CS 2012 | Question 12
- GATE | GATE CS 2012 | Question 11
- GATE | GATE CS 2012 | Question 10
- GATE | GATE CS 2012 | Question 9
- GATE | GATE CS 2012 | Question 8
- GATE | GATE CS 2012 | Question 7
- GATE | GATE CS 2012 | Question 65
- GATE | GATE CS 2012 | Question 15
- GATE | GATE CS 2012 | Question 16
- GATE | GATE CS 2012 | Question 24
- GATE | GATE CS 2012 | Question 23
- GATE | GATE CS 2012 | Question 22





