Heap, the data structure!

Shahad Mahmud
2 min readApr 12, 2020

A heap is a special tree-based data structure where the tree is a complete tree or an almost complete tree which satisfy the heap property. Now, what is heap property? The heap property states that in a heap all the keys of children nodes must be greater than or equal or less than or equal of the key of the parent node. Based on the heap property there are two kinds of heaps:

Max heap

In the max heap, the key of a node is greater than or equal of all the child nodes and the key of the root is the greatest.

A max heap
Max heap

Min heap

In the max heap, the key of a node is less than or equal of all the child nodes and the key of the root is the minimum.

The min heap
Min heap

There are different types of heaps. Some of them are Binary heap, Binominal heap, Fibonacci heap, Leftist heap, K-D heap etc.

Heap is mostly used for the implementation of the priority queue.

--

--

Shahad Mahmud

I’m a computer science and engineering graduate. I’m passionate about learning and spread what I learn. Besides I like cooking and photography!