The GATE Grind

GATE 2014 CS (CS3) – Question 28

Compiler Design · Runtime Environments · 1 mark · Multiple choice

Which statements are correct?
1. Static allocation of all data areas by a compiler makes recursion impossible.
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.

  1. 1 and 2 only
  2. 2 and 3 only
  3. 3 and 4 only
  4. 1 and 3 only

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) 1 and 3 only

Explanation

Multiple simultaneously active invocations need separate activation records, so a single statically allocated record per procedure cannot implement general recursion. Records must be created as calls occur, commonly on a runtime stack. Garbage collection and both heap plus stack are not essential. Thus **1and3only,D** under the standard general-recursion model.