The Gateway to Computer Science Excellence
+15 votes
2.3k views

Which languages necessarily need heap allocation in the runtime environment?

  1. Those that support recursion.
  2. Those that use dynamic scoping.
  3. Those that allow dynamic data structure.
  4. Those that use global variables.
in Compiler Design by Veteran (105k points)
edited by | 2.3k views
+1
same Q appeared in ISRO 2017 dec ..
0

Same as previous year question

https://gateoverflow.in/2226/gate1997-1-10

2 Answers

+29 votes
Best answer
Those that allow dynamic data structure.

malloc etc uses memory from heap area.
by Boss (11k points)
edited by
0
Why not option A ,because during recursion the stack gets overflowed and hence we need memory from the heap for variables?
+1
remember stack overflow:)
0

We store global variable in heap memory.

then why not option D also?

@sushmita

@Sankaranarayanan P.N

@jothee

+1

@jlimbasiya Global variables are stored in the data section of the program, not heap, because on heap we can only access memory through pointers. But in many programs we do not necessarily use malloc(), calloc() etc to define global variables. 

+5 votes

C

 Heap allocation is needed for dynamic data structures like tree, linked list, etc

by Active (4.5k points)
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,370 answers
198,506 comments
105,276 users