A Heap is a special Tree-based data structure in which the tree is a complete binary tree.
- Max Heap: In a max heap, the root node must be the largest among all other nodes in the heap, and every node must be greater than or equal to its children.
- Min Heap: In a min heap, the root node must be the smallest among all other nodes in the heap, and every node must be less than or equal to its children.
Heapify :
It is a process in which an unordered binary tree is transformed into a valid heap by adjusting/pushing the nodes upwards or downwards in the tree to satisfy the heap property, either the max-heap property (where the parent node is greater than or equal to its children) or the min-heap property (where the parent node is less than or equal to its children).