The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+10 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

asked in Compiler Design by Veteran (59.6k points) | 1.5k views

same question asked in 2010

3 Answers

+15 votes
Best answer

Memory is taken from heap for dynamic allocation.

So, option (B) is correct.

answered by Boss (11.5k points)
edited by
plz tell meaning of dynamic scope rule

In dynamic scoping, you search in the local function first, then you search in the function that called the local function, then you search in the function that called that function, and so on.

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

why C) is not correct?
by mistake you type B is not correct.

here B is correct
yes sorry now chk
+7 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.

answered by Active (4.5k points)
globally scope variable not used in heap?

I think Heap is used where dynamic memory allocation usually takes place(memory can be allocate and deallocated at run time or at any time depending upon user's requirement).

global and static variables are stored in data in this segment is initialized by the kernel  before the program starts executing.all uninitialized global variables and static variables are initialized to zero .

recursion is also supported by heap allocation.

in c we can also use global variable in heap explicitely with malloc() and free().

Hello rajoramanoj

explain your reasoning behind option C.

I'm unable to relate dynamic scoping with global variables. As per my knowledge Dynamic scoping is no where related to heap are. It's related to stack although.
0 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.
answered by Junior (711 points)

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

42,599 questions
48,601 answers
63,740 users