The heap is the best type of tree that meets certain conditions as it is a complete binary tree and the value of the parent node in the heap is always greater than or equal to the value of its child nodes in the case of the maximum heap. ۔ The value in the parent node is smaller than the value stored in its child node. This type of data structure is designed to implement scenarios such as priority rows where one needs to select the element with the least or the highest priority. And the tree in a heap is always balanced.

## Heap Data Structure Types

- Min Heap
- Max Heap
- Binary Heap

## Min Heap in Data Structure

This is a type of heap where the value of elements reserved in the root node is smaller or equal to the value of elements saved in its child node.

### Algorithm

**Step 1:**First make a new node “N” at the end of the heap.**Step 2:**New element to be added will be assigned to this node N**Step 3:**Replicate Step 3 and 4 until the node come to its perfect position.**Step 4:**Values of this node N is differentiated to the parent of N.**Step 5:**If the value of parent [N] > any of its child then exchange them.

#### Working

Min heap is a total binary tree that keeps the elements in its node following one criterion .e Parent [N] is smaller than or equal to its child node.

It assists in applications where one requires to sort the elements in rising order such as importance strings as the least element in the heap is present at the root and can be released one by one and build a heap on the remaining elements in the heap likewise.

## Max Heap in Data Structure

Max heap where the value in the root element is more prominent or equal to the element current in its child node.

### Algorithm

**Step 1:**First make a new node N at the end of the heap.**Step 2:**New element to be added will be assigned to this node N**Step 3:**Replicate Step 3 and 4 until the node come into its perfect position.**Step 3:**Values of this node N is different to the parent of N.**Step 4:**If the value of parent [N] < any of its child then exchane them.

#### Working

Max heap is a full binary tree that keeps the elements in its node following one criterion .e Parent [N] is more prominent or equal to its child node.

It supports applications where one requires to sort the elements in reducing order as the most increased element in the heap is existing at the root and can be released one by one and build a heap on the remaining elements in the heap likewise.

## Binary Heap

A binary heap is a binary tree that fulfills all the properties of a whole binary tree. The additional binary heap can be expressed using the above 2.

### Conclusion

Heap data structure is a superior type of level, the full binary tree that exists either as **max –heap** where the value of the parent node is constantly greater than or equal to the value in the child node or as **min-heap** where the value of the parent node is smaller or equal to the values in its child node.