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

Discussion

The languages that need heap allocation in the runtime environment are

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

Answer: D

Heap allocation is needed by languages that allow dynamic data structures.

Data structures created at run time with no fixed lifetime, such as linked lists and trees built with malloc or new, must outlive the procedure that created them, so they cannot live on the stack. They are allocated from the heap.

Global variables are allocated statically. Recursion is handled with a stack of activation records, and dynamic scoping is also implemented on the stack. None of these by itself requires a heap.

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

Post your comment

Please log in or register to post a comment.