Skip to content
Official PYQ · 1997

GATE CS 1997 Q1.10 — Runtime Environments

Explain with AI

Heap allocation is required for languages.

Choose one option
View worked solution

Answer: B

Memory allocation in programming languages is managed using different memory areas depending on the lifetime of the data:

  • Stack Allocation: Used for local variables and function activation records. Since function calls follow a Last-In-First-Out (LIFO) order, stack allocation is sufficient to support recursion (Option A).
  • Heap Allocation: Used when the lifetime of a data object is independent of the scope or activation record that created it. This is essential for dynamic data structures (like linked lists, trees, or graphs) where memory is allocated and deallocated dynamically at runtime (Option B).
  • Dynamic Scope Rules: These determine how free variables are resolved at runtime. They can be implemented using a stack (e.g., association lists or central environments) and do not inherently require a heap (Option C).

Thus, heap allocation is specifically required for languages that support dynamic data structures.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Runtime Environments questions