Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the difference between Stack and Heap and what is it?

user-image
Question added by Ashfaque Choudhary , Programmer Analyst , Almarai
Date Posted: 2014/11/15
Ibraheem AlKilanny
by Ibraheem AlKilanny , Software Development Team Leader , UnifiAccess

Stack is a data-structure which maintains its elements as last-in-first-out. You can imagine a stack as some rocks on each other, so you cannot remove the elements in the bottom without removing first the elements at the top. This order is very important in computer, especially when dealing with function calls and math inductions (recursion).

Heap is sometimes called (priority-queue), which is a type of queue that not fearly orders its elements. That is, in the natural queue, the first element enters the queue is the first one to go out. But in a heap, the first element goes out is the one having the most top priority, regardless of enetering first or last.

More Questions Like This