|
Inside computer science a heap is a specialised tree-based data structure. Its base datatype (utilized for node keys) must exist as an ordered set.
Let The & B exist as nodes of the heap, such that B occurs as kid of The. A heap must so satisfy a below affliction (heap property):
This is the exclusively restriction of general heaps. In that form it implies that the greatest element is universally in the root node, & such the heap is occasionally known as a liquid ecstasy heap. (Or else, around case the comparison is reversed, a little element is universally in the root node, which final result in a min heap.) Due to this fact, heaps come utilized to implement priority queues. A efficiency of heap operations is important around many graph algorithms.
the operations normally performed around a heap are
delete-max or even delete-min: removing the root node of a max- or even min-heap, severally,
decrease-key: updating a key inside the heap, and
insert: adding the recently key to the heap.
Heaps come utilized in the sorting algorithm known as heapsort.
Variants
Binary heap
Binomial heap
Fibonacci heap
Soft heap
2-3 heap
Treap
|