The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+10 votes
1.5k views

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
+1

same question asked in 2010

https://gateoverflow.in/2187/gate2010-14

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
+1
plz tell meaning of dynamic scope rule
+3

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.

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

here B is correct
0
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)
0
globally scope variable not used in heap?
+1

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 segment.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().

0
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
155,674 comments
63,740 users