quote:A heap is a complete binary tree with the following ordering property: The value of every parent node is greater than or equal to the values of either of its daughter nodes. The largest node is always the root.Is there any connection between the two? cheers, Jack
C++'s 'heap' area - definition?
hi all,
just a quick question. I''m sure I''ve got the wrong-end-of-the-stick here (so to speak) here... but was wondering if anyone could clarify
I know that in C++ memory allocation can be from the ''heap'' area. I''ve just been reading up on some ADT''s and come across the heap ADT - any corrolation? (I couldn''t find it discussed in Stroustrups C++ book).
they are two different meanings of the word "heap"... one is an ADT, and the other is memory you allocate with "new".
The only connection is that usually the C/C++ heap (memory allocated with malloc/new) is actually implemented using a heap algorithm
quote:The only connection is that usually the C/C++ heap (memory allocated with malloc/new) is actually implemented using a heap algorithm
thats the thing I was curious about. I know that they (on face value) seem to be completely different things... but wondering if the naming of the memory-space was influenced in some way by the ADT.
Jack
quote:Original post by jollyjeffers
but wondering if the naming of the memory-space was influenced in some way by the ADT.
The proper term for "the heap" is arena.
No, heap and heap are unrelated. period.
One is a tree like data structure, the other is just a name USED to describe the memory allocation method also known as:
heap
free store
arena
anonymous memory
the definition of all these is just that the allocated memory isn''t destroyed by any scope. (see stack)
One is a tree like data structure, the other is just a name USED to describe the memory allocation method also known as:
heap
free store
arena
anonymous memory
the definition of all these is just that the allocated memory isn''t destroyed by any scope. (see stack)
quote:No, heap and heap are unrelated. period.
quote:The only connection is that usually the C/C++ heap (memory allocated with malloc/new) is actually implemented using a heap algorithm
hmm, conflicting
ah well.. not that I suppose it matters
Jack
Okay, if you want to be picky. It should be "usually implemented", not "actually implemented"
quote:Original post by daerid
Okay, if you want to be picky. It should be "usually implemented", not "actually implemented"
Try "never implemented". The heap is a region of memory allocated to the process beginning directly after the last memory address used for program data.
Under linux, the heap is represented by a pointer to the top of the heap, known as the break value. This value is grown using the brk system call, although that is taken care of by malloc() (new operator).
There is no correlation at all between the tree data structure known as a heap and the region of memory allocated to a process also known a heap (among other names).
EDIT: spelling
[edited by - kevmo on December 15, 2003 8:25:48 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement