in Compiler Design edited by
8,343 views
24 votes
24 votes

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 edited by
8.3k views

2 Comments

same Q appeared in ISRO 2017 dec ..
4
4

Same as previous year question

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

1
1

3 Answers

39 votes
39 votes
Best answer
Those that allow dynamic data structure.

malloc etc uses memory from heap area.
edited by

4 Comments

Why not option A ,because during recursion the stack gets overflowed and hence we need memory from the heap for variables?
0
0
remember stack overflow:)
1
1

We store global variable in heap memory.

then why not option D also?

@sushmita

@Sankaranarayanan P.N

@jothee

0
0

@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. 

4
4
5 votes
5 votes

C

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

0 votes
0 votes
All of the options shsould be correct here
Answer:

Related questions