|
This section contains 391 words (approx. 2 pages at 300 words per page) |
The heap is that part of the computer's working memory that is reserved for data whose function and size cannot be specified until a program is executed at run time. The assignment of such memory to a process at run time is carried out by means of dynamic memory allocation. A program may continue to accept data from numerous users, store them in heap storage, and wait to commence processing until all the data have been received. To set aside a particular amount of heap storage makes it easier to manage the overall storage capacity of the computer system and allows the operating system to operate more efficiently. Allocation of heap storage is performed by (1) having applications request, when needed, a certain portion of the total allowed heap (called a "heap block"), (2) having applications give their blocks to the free heap when they no longer need them, and (3) periodic reorganization of the used and unused heap blocks. To manage the heap, programming languages such as C++ include procedures for requesting, accessing, and freeing up blocks of memory.
The term heap was apparently inspired by the term stack. Stack memory is an area of memory reserved for data whose function and size can be determined when the program is compiled. As a program runs, stack memory blocks may be moved about so that small free blocks can be merged together into larger ones to meet the program's needs. In contrast to stack blocks, heap blocks are not freed in reverse of the order in which they were allocated, so free blocks may be mingled with blocks that are in use. Generally, however, stack and heap are similar enough in design that a portion of a heap (called a subheap) is usually treated like a stack.
Heapsort is an efficient sorting method used with heap storage that first arranges the address fields into a heap structure (called a binary tree) and then repeatedly removes the root of the heap as the data in the root is used (freeing up that space) and re-organizes the heap. The root is by definition the largest-valued field, always located at the top of the binary tree. A binary tree is a data structure used for sorting and storing data at nodes (or "junctions") that contain at most two leaves (data items attached to a node).
|
This section contains 391 words (approx. 2 pages at 300 words per page) |
