what is the difference b/w stack and heap.........?
$kr
2008-09-21 03:04:26 UTC
give as many as u can.............
Eight answers:
Michael F
2008-09-21 03:38:44 UTC
Each program that executes is alloted an area of memory to run. It is given some extra memory to hold data that it needs to run (e.g. local variables). That is the stack. The heap is memory outside the program "run" memory.
anonymous
2008-09-21 10:16:58 UTC
a heap is a specialized tree-based data structure that satisfies the heap property: if B is a child node of A, then key(A) ≥ key(B). This implies that an element with the greatest key is always in the root node, and so such a heap is sometimes called a max heap. This is why heaps are used to implement priority queues. The efficiency of heap operations is crucial in several graph algorithms.
a stack is an abstract data type and data structure based on the principle of Last In First Out (LIFO). Stacks are used extensively at every level of a modern computer system. For example, a modern PC uses stacks at the architecture level, which are used in the basic design of an operating system for interrupt handling and operating system function calls. Among other uses, stacks are used to run a Java Virtual Machine, and the Java language itself has a class called "Stack", which can be used by the programmer. The stack is ubiquitous.
Krishna K
2008-09-21 13:47:19 UTC
Heap is the Priority Queue.Priority Queue is the Queue depending upon the size.It is the same diff between the stack and Queue.
Barbie
2008-09-21 10:17:22 UTC
a stack is in an apple pie order
whereas a heap is in a bulk quantity....
for eg..a stack of books
n a heap of leaves
pralad11
2008-09-21 10:20:51 UTC
stack is LIFO,ie last in first out.imagine a garland of pearls which is knotted at one end,the last pearl which is added is the first to be removed.heap is nothing but piling of data.it forms a tree.tree arranged in either ascending or descendin order is called a heap.a heap is a tree,but a tree is not a heap..
anonymous
2008-09-21 10:12:28 UTC
a stack is often an organized group of objects that fit onto one and other in a sturdy fashion. a heap is a random pile.
bob b
2008-09-21 10:11:51 UTC
If i remember right a stack is first in first out(FIFO) a heap is the opposite(last in last out(LILO))
Livin' On Love
2008-09-21 10:11:34 UTC
a 'stack' is rather small, a heap is an overwhelming amount.. eh?
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.