Heap is a specialized tree-based data structure and is used to represent the priority queue. In the heap-sort algorithm, we have two heaps min-heap and max-heap.
Let’s take the input as [6,8,9,2,4]
In the Min-heap, the “Parent node should be less than or equal to the child node”. Let’s…