GATE | GATE CS 2008 | Question 54
Which of the following are true?
I. A programming language which does not permit global variables of any
kind and has no nesting of procedures/functions, but permits recursion
can be implemented with static storage allocation
II. Multi-level access link (or display) arrangement is needed to arrange
activation records only if the programming language being implemented
has nesting of procedures/functions
III. Recursion in programming languages cannot be implemented with dynamic
storage allocation
IV. Nesting of procedures/functions and recursion require a dynamic heap
allocation scheme and cannot be implemented with a stack-based allocation
scheme for activation records
V. Programming languages which permit a function to return a function as its
result cannot be implemented with a stack-based storage allocation scheme
for activation records
(A) II and V only
(B) I, III and IV only
(C) I, II and V only
(D) II, III and V only
Answer: (A)
Explanation: I. Recursion cannot be implemented with Static Storage Allocation.  Static allocation means, compiler has to decide size for function calls. In case of recursion, it is not possible for compiler to decide as depth of recursion depends on recursion parameter which may be an input from user also.
II. Is CORRECT. Programming languages that support nested subroutines also have a field in the call frame that points to the stack frame of the latest activation of the procedure that most closely encapsulates the callee, i.e. the immediate scope of the callee. This is called an access link or static link (as it keeps track of static nesting during dynamic and recursive calls) and provides the routine (as well as any other routines it may invoke) access to the local data of its encapsulating routines at every nesting level. Some architectures, compilers, or optimization cases store one link for each enclosing level (not just the immediately enclosing), so that deeply nested routines that access shallow data do not have to traverse several links; this strategy is often called a “display” [Source: https://en.wikipedia.org/wiki/Call_stack ]
III. Recursion CAN be implemented with any kind of Dynamic Storage Allocation scheme.
IV. Nesting features are always implemented in a language using STACK and NOT Heap. (See above point II for details)
V. Is CORRECT. In stack based allocation scheme, once a function has returned, it is removed from function call stack. Therefore returning a function from a function doesn’t look possible.
Quiz of this Question
Last Updated :
28 Jun, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...