Jump to content

Heap (data structure)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 129.116.166.14 (talk) at 13:30, 9 August 2002 (Moved stuff on Binary heap to separate article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A heap is a specialized tree-based data structure. Its base datatype (used for node keys) must be an ordered set.

Let A and B are nodes of a heap, such that B is a child of A. The heap must then satisfy following condition (heap property):

key(A) ≥ key(B)

This is the only restriction of general heaps. It implies that the greatest (or the smallest, depending on the semantics of a comparison) element is always in root node. Due to this fact, heaps are used to implement priority queues. The efficiency of heap operations is crucial in several graph algorithms.

Common variants include:

External links: