Let A and B be nodes of a heap, such that B is a child of A. The heap must then satisfy the following condition (heap property):
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.
Heaps are used in the sorting algorithm called heapsort.
Common variants include:
Search Encyclopedia
|
Featured Article
|