Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which languages necessarily need heap allocation in the run time environment?

  • A.Those that support recursion
  • B.Those that use dynamic scoping
  • C.Those that use global variables
  • D.Those that allow dynamic data structures

Answer: D

Correct answer: Those that allow dynamic data structures

A heap is needed when the amount of storage required is not known until run time, and when objects must outlive the function that created them. Dynamic data structures - lists, trees, growable arrays - require exactly that.

Recursion needs only a stack, since each activation is destroyed in reverse order of creation. Dynamic scoping is a name-resolution rule, and global variables have static storage decided at compile time. None of those three forces a heap.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.