Heap


Heap

Heap is a particular case of balanced binary tree data structure where the root-node key is compared with its children and arranged accordingly. If α has child node β, then −

key (α) ≥ key (β)

Since the value of a parent is greater than that of a child, this asset produces Max Heap. According to this, the bulk can be of two types -

Input → 35 33 42 10 14 19 27 44 26 31

Min-Heap - When the root node value is less than or equal to one of its offspring.

Max-Heap - When the number of root nodes is greater than or equal to one of its offspring.