Question

In some languages, dynamically allocated objects are stored in the heap. Looking at a complexity table of data structures (like this one) I see that the only advantage heaps have over some other type of data structures such as a tree is dealing with the maximal value better.

Why is the heap used to store those objects and not other data structures?
Is dealing with the maximal value important for memory management? Why?

Was it helpful?

Solution

The "heap" which is used to store dynamically allocated objects is completely unrelated to the data structure which is called a "heap". They are two completely different things with the same name.

See Wikipedia for a reference on both kinds of heaps. It links to one article for "Heap (data structure)", and another for "Heap (free store)".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top