7,075 views
19 votes
19 votes

Heap allocation is required for languages.

  1. that support recursion

  2. that support dynamic data structure

  3. that use dynamic scope rules

  4. None of the above

4 Answers

Best answer
22 votes
22 votes

Memory is taken from heap for dynamic allocation.

So, option (B) is correct.

11 votes
11 votes

A. false bcoz When a function is called recursively, a stack frame is allocated for each of the recursive call of the function.

B. true bcoz  Heap allocation is needed for dynamic data structures like tree, linked list, etc.

C. false bcoz Dynamic scoping is useful as a substitute for globally scoped variables.

2 votes
2 votes
  1. not necessary we can do it by stack allocation only.
  2. for this heap allocation necessary without heap allocation we can not use dynamic data structures like linked lists this can be implemented in the heap area only so that users can allocate, deallocate memory whenever they want using function like malloc(), free() (in case of C programming language).
  3. not necessary we can do it by stack allocation only. Dynamic scoping is useful as a substitute for globally scoped variables.

GATE CSE 2010 | Question: 14 - GATE Overflow

Static and Dynamic Scoping - GeeksforGeeks 

https://stackoverflow.com/questions/14588767/where-in-memory-are-my-variables-stored-in-c

https://www.geeksforgeeks.org/memory-layout-of-c-program/

1 votes
1 votes
(B ) heap allocation dynamic data structure reason (dynamic data structure -: those data structure whose size inc or dec at runtime so we don't know the actual size e.g stack,queue.
Answer:

Related questions

34 votes
34 votes
3 answers
4
Kathleen asked Sep 29, 2014
10,944 views
Dirty bit for a page in a page tablehelps avoid unnecessary writes on a paging devicehelps maintain LRU informationallows only read on a pageNone of the above