+ 5

What is a heap?

14th Jun 2017, 8:26 AM
Kenshin Himura
Kenshin Himura - avatar
4 Answers
+ 3
@Augustin close. Stack is this stack of porcelain plates. You break the stack if you break the last in first out order. Heap is a heap of silverware. You can put a spoon in and you can take a spoon out. No ordering required.
14th Jun 2017, 9:10 AM
Venkatesh Pitta
Venkatesh Pitta - avatar
+ 7
A place inside the Computer where you store data and can have access to any of your data at any time. It is the opposite of "stack" where you can only access your stored data one at a time according to LIFO: Last-In-First-Out. ^-^
14th Jun 2017, 8:54 AM
Femyk
Femyk - avatar
+ 4
to me, I think heap is a alternate memory where we have superpowers like deleting values after use....I know its kind of vague but do you think am I right?
14th Jun 2017, 8:55 AM
Kenshin Himura
Kenshin Himura - avatar
+ 3
It is a data structure. A specialised tree is how it is implemented in most cases. The most important item always bubbles up to the top, and any other item is within log-base-2(height-of-the-tree) steps of looking for it. Really, study a data structures book. Or, if you like a rather hands-on approach, look at https://github.com/phishman3579/java-algorithms-implementation there is a Java implementation of heap in there. I overlooked the C++ tag. Here is a C++ implementation, again, on github: https://github.com/plamenko/altruct
14th Jun 2017, 8:41 AM
Venkatesh Pitta
Venkatesh Pitta - avatar