(redirected from heaps)
Also found in: Dictionary, Thesaurus, Legal, Acronyms, Idioms, Wikipedia.


An area of memory used for dynamic memory allocation where blocks of memory are allocated and freed in an arbitrary order and the pattern of allocation and size of blocks is not known until run time. Typically, a program has one heap which it may use for several different purposes.

Heap is required by languages in which functions can return arbitrary data structures or functions with free variables (see closure). In C functions malloc and free provide access to the heap.

Contrast stack. See also dangling pointer.


A data structure with its elements partially ordered (sorted) such that finding either the minimum or the maximum (but not both) of the elements is computationally inexpensive (independent of the number of elements), while both adding a new item and finding each subsequent smallest/largest element can be done in O(log n) time, where n is the number of elements.

Formally, a heap is a binary tree with a key in each node, such that all the leaves of the tree are on two adjacent levels; all leaves on the lowest level occur to the left and all levels, except possibly the lowest, are filled; and the key in the root is at least as large as the keys in its children (if any), and the left and right subtrees (if they exist) are again heaps.

Note that the last condition assumes that the goal is finding the minimum quickly.

Heaps are often implemented as one-dimensional arrays. Still assuming that the goal is finding the minimum quickly the invariant is

heap[i] <= heap[2*i] and heap[i] <= heap[2*i+1] for all i,

where heap[i] denotes the i-th element, heap[1] being the first. Heaps can be used to implement priority queues or in sort algorithms.


In programming, it refers to a common pool of memory that is available to the program. The management of the heap is either done by the applications themselves, allocating and deallocating memory as required, or by the operating system or other system program.
References in periodicals archive ?
Talking to this agency, Dr Faisal Iftikhar said people with respiratory issues were visiting his clinic frequently these days because of the unhealthy environment caused by dirty nullahs and garbage heaps .
He demanded that Capital Development Authority (CDA) should take steps for proper removal of the garbage heaps and cleanliness of the nullahs to avoid environmental and health problems.
com/the-daily-dish/rob-heaps-accent-imposters) Bravo in February, Heaps explained why he got particularly interested in Holmes' podcast.
Un-ginned cotton heaps are not formed in any geometrical shape so the surveyor has to assign an imaginary geometrical shape of rectangular prism to each heap by cutting down the side edges and peak of heaps.
Mr Heaps is the former chairman of corporate law firm Eversheds.
Back in 2006 a planning application was lodged to convert Heaps Mill into apartments.
The decision to reject the application means Heaps will now have to serve a minimum of 28 years behind bars before he can even apply for release on licence.
Heaps admitted causing a public nuisance by making hoax and abusive calls and was told at Wolverhampton Crown Court by Judge John Warner only immediate custody was appropriate for his actions.
Heaps, of Newport, South Wales, denied starting the late-night blaze in Everton, Liverpool, last December.
Toddler Francesca Bimpson was asleep in bed when Graham Heaps, 44, set fire to the home of his former lover's relatives because he was "bitter" over the breakdown of their relationship, Liverpool Crown Court was told.