A heap is a non-linear tree-based data structure where the tree is a complete binary tree. A tree is said to be a complete binary tree if all the levels of the tree are filled completely. The heap data structure is of 2 types- min-heap and max-heap. Min-heap: When the element in the root node is the smallest among all the nodes, the heap is said to be the min-heap. Max-heap: When the element in the root node is largest among all the nodes, the heap is said to be the max-heap.