Last Updated on June 28, 2022 by Ria Pathak

### What is Heap?

A heap is a complete binary tree, A complete binary tree is a binary tree in which all the levels are completely filled except the last level i.e. leaf node.

### What is a Heap Sort Algorithm?

Heap Sort is a popular sorting Algorithm that processes the element by creating the min-heap or max-heap using the given array. Min-heap or max-heap represents the ordering of the array; the value of the root element will represent the minimum or maximum element of the array.

The basic concept of heap sort is to eliminate the elements one by one from the heap and then insert them in a sorted manner.

### How to “heapify” a tree?

So, we can modify the tree in the max heap or min-heap. In other words, we can say, The reshaping of a binary tree into a heap tree is called heapify.

### Working of Heap sort:

In heap sort, there are two phases for sorting the elements. They are as follows:

- In the first step, we’ll create a heap by adjusting the elements of the array.
- After creating the heap, remove the root element repeatedly by swapping it with the last element of the array.

Generally, Heap data structures are taught with heap sort. Basically, the Heap sort algorithm has a limited number of uses because quicksort is better than heap sort. Following are uses of the heap:

**Priority Queue:**Heap is used in the construction of the priority queue efficiently. You can easily insert, delete, and identify priority elements, or you can insert and extract the element with priority in the time complexity of O(log n).**Graph Algorithms:**Heap Implemented priority queues are also used in graph algorithms, such as Dijkstra’s algorithm and prim’s algorithm.**Order Statistics:**We can easily use Heap data structures to find the kth largest/ smallest element in the array.**Embedded System:**We can use heap data structure effectively in systems concerned with security and also in embedded systems such as Linux kernel.

This article tried to discuss the **Applications of Heap data structures**. Hope this blog helps you understand the concept. To practice problems on Heap you can check out MYCODE | Competitive Programming – Heaps.