Which of the following statements is/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.
- II and V only
- BI, III and IV only
- CI, II and V only
- DII, III and IV only
Explanation
I is false: recursion inherently needs multiple simultaneous instances of a function's locals, which static (single, fixed-location) allocation cannot support. II is true: access links/displays exist specifically to handle nested-scope variable access — unneeded without nesting. III is false: dynamic stack-based allocation is exactly the STANDARD way recursion is implemented. IV is false: recursion and nesting are typically implemented via stack-based (not heap) allocation. V is true: if a function can return another function (a closure) that references the enclosing frame's variables, that frame can't be safely popped on return via simple LIFO discipline — requiring heap allocation instead.
Source: GATE CS 2008 (2008)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.