The Gateway to Computer Science Excellence
+1 vote
Does Heap Allocation support both recursion and dynamic memory allocation? Because,a stack can be implemented using dynamic memory allocation.Please correct me.

Test Series answer shows only dynamic memory allocation
in Compiler Design by | 401 views
In heap we cannot practically create activation records as we cannot guess the size of it. But stack does it for us.
So what is the answer? No support for recursion using heaps?
Yes @sripo
please add the test series name on the top
Think it is Made Easy or the one who shall not be named one of them don't remember exactly.

Refer Arjun sir's reply on the above link. Might be of help

1 Answer

+1 vote
Best answer
Heap support dynamic allocation but not recursion

because recursion need stack structure

now one thing more

If you are willing to convert your recursion to iteration, then it is possible to use only heap space, but that isn't really recursion. You would do so by implementing a stack in the heap.
selected by
A Heap can be implemented as a stack thereby making heap recursive.That is my doubt.
heap is the reserve  area in the PCB where the dynamic allocation can take palce . now come to the point ,in this area we can simulate the stack (think as we can make the stack ) and the recursive process can take place in that stack .
now the concluson is that  heap is the area in which we made  the stack ,so the recursion property is not support by the heap itself it is support by the stack made in the heap area
Doubt cleared.
Thanks a lot
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
52,345 questions
60,513 answers
95,360 users