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 :
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.

(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




