Book contents
5 - Heaps
Published online by Cambridge University Press: 25 January 2011
Summary
Heaps are, after the search trees, the second most studied type of data structure. As abstract structure they are also called priority queues, and they keep track of a set of objects, each object having a key value (the priority), and support the operations to insert an object, find the object of minimum key (find min), and delete the object of minimum key (delete min). So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible. Of course, we can replace everywhere the minimum by maximum; where this distinction is important, one type is called the min-heap and the other the max-heap. If we need both types of operations, the structure is called a double-ended heap, which is a bit more complicated.
The heap structure was originally invented by Williams (1964) for the very special application of sorting, although he did already present it as a separate data structure with possibly further applications. But it was recognized only much later that heaps have many other, and indeed more important, applications. Still, the connection to sorting is important because the lower bound of Ω(n log n) on comparison-based sorting of n objects implies a lower bound on the complexity of the heap operations. We can sort by first inserting all objects in the heap and then performing find min and delete min operations to recover the objects, sorted in increasing order.
- Type
- Chapter
- Information
- Advanced Data Structures , pp. 209 - 277Publisher: Cambridge University PressPrint publication year: 2008