Definition
![](images/tree.png)
A MinHeap is a complete binary tree where the value stored in any of its nodes is less than or equal to the values stored in its child nodes.
REPRESENTATION
Being a complete binary tree, the most appropriate representation for a heap is the sequential representation. So it is enough to store in a vector the information associated with the nodes, the relationships between the nodes being described by the formulas:- st(x)=2*x (if 2*x<=n) or NULL (if 2*x>n);
- dr(x)=2*x+1(if 2*x+1<=n) or NULL (if 2*x+1>n);
- tata(x)=[x/2] (if x>1) or NULL (if x=1 is the root);
- where x is a random node from the graph and n is the number of nodes in the tree