GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 1.10

Why a language needs heap storage

Compiler Design · Runtime Environments & Parameter Passing · Full GATE CSE 1997 paper

GATE 1997, Q1.10 1 mark · MCQ
Report issue

Runtime Environments & Parameter Passing

Question 1.10, GATE 1997: Choose the feature motivating heap allocation: recursion, dynamic data structures, dynamic scope, none.
Tap to enlarge
Your answer
Answer & solution

Answer: B / listed item 2 (no official key was published)

Recursion normally creates nested activation lifetimes, which a stack handles. Dynamic scope concerns name lookup and does not itself force arbitrary object lifetimes. General dynamic structures such as linked nodes may be allocated and released in an order unrelated to calls and returns, so they need storage managed outside a strict activation stack: the heap, item 2. This is the conventional distinction. Particular bounded or region-scoped structures could use specialized pools, so “required” refers to supporting general dynamic lifetimes, not every individual dynamic object.

Original paper, page 2