GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 18

GATE CSE 2014 Set 3 Q18

Compiler Design · Runtime Environments & Parameter Passing · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q18 1 mark · MCQ
Report issue

Runtime Environments & Parameter Passing

Question 18, GATE 2014: Evaluate: (1) statically allocating every data area prevents recursion; (2) automatic garbage collection is essential for recursion; (3) dynamic allocation of activation records is essential for recursion; (4) both heap and stack are essential for recursion. Choose A 1,2 only; B 2,3 only; C 3,4 only; D 1,3 only.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: D under the general recursion storage model

Step 1: General recursive calls can leave multiple invocations of the same procedure simultaneously active. Each needs its own parameters, local variables, return address and other activation information. Step 2: One fixed static record per procedure cannot preserve all these activations; records must be allocated as calls occur. This is the intended sense in which 1 and 3 hold. Step 3: A runtime stack allocates and reclaims activation records without a heap or automatic garbage collector, refuting 2 and 4. Thus D. Bounded recursion or tail-call elimination can use fixed storage, so these claims concern the conventional general recursion model, not every special recursive program.

Original paper, page 57 · Answer key