GateAI
Runtime Environments

GATE CSE 2014 Set 3 · Q18

MCQ1 markMedium

Time

Which of the following statements are CORRECT? 1) Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2) Automatic garbage collection is essential to implement recursion. 3) Dynamic allocation of activation records is essential to implement recursion. 4) Both heap and stack are essential to implement recursion.

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) 1 and 3 only

Runtime Environments

Let us evaluate the given statements regarding runtime memory management and recursion:

  1. Statement 1 is CORRECT: If all data areas are statically allocated, each function has only a single fixed memory location for its parameters and local variables. A recursive call would overwrite the values of the previous active invocation, making recursion impossible (as was the case in early Fortran).

  2. Statement 2 is INCORRECT: Automatic garbage collection is used for reclaiming unreachable heap-allocated memory, but recursion simply relies on a call stack where activation records are pushed/popped following a LIFO pattern.

  3. Statement 3 is CORRECT: To support recursion, each call must dynamically allocate an activation record (stack frame) on the call stack at runtime to maintain independent states for simultaneous active invocations.

  4. Statement 4 is INCORRECT: A call stack is sufficient to implement recursion; dynamic heap allocation is not necessary for recursive control flow.

Therefore, statements 1 and 3 only are correct, which corresponds to option (D).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Runtime Environments previous year question is Q18 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Runtime Environments in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Runtime Environments PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Runtime Environments in GATE CSE

Runtime Environments has 7 GATE CSE PYQs across 7 papers from 2012 to 2023. 4 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 3.

How GATE tests Runtime Environments

More from GATE CSE 2014 Set 3

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 3 · Q18 · MCQ

Which of the following statements are CORRECT? 1) Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2) Automatic garbage collection is essential to implement recursion. 3) Dynamic allocation of activation records is essential to implement recursion. 4) Both heap and stack are essential to implement recursion.

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.