What is the relationship between the heap used in dynamic memory allocation and the data structure?

Possible duplicate:
Why are two different concepts called a "heap"?

I googled around, but cannot find the answer to this question; What is the relationship between the heap used in dynamic memory allocation and the data structure? Is the memory organized on the heap in a manner similar to the heap data structure? If this is the case, it seems very strange, since the memory sample must be random access AFAIK (i.e. O (1)), but the search for an element from the heap is not performed at a constant time.

So, is this just an overloaded sense of the heap, so to speak, or is there some kind of connection?

+3
source share
3 answers

Heap is synonymous with what the standard calls free storage. Unlike stacks, which are used for function calls, as well as for storing object objects, heaps grow in the opposite direction (from top to bottom) in many implementations (as opposed to stacks that grow from bottom to top). Of course, not one of them is required by the standard.

The heap data structure, on the other hand, is completely different - it is a specialized tree structure with certain properties.

Perhaps some implementations use the heap data structure to manage free stores, where the name might have come from. (See buddy memory allocation .)

+5
source

, . , . .

+2

There is no relation, but I admit that this name can be misleading. A heap in memory is an array that the OS allocates to programs. A bunch of implemented programs for quick searches.

0
source

Source: https://habr.com/ru/post/1736157/


All Articles