A heap is specialized tree-based data structure which is essentially an complete binary tree which satisfies the heap property.
Also it is efficient implementation of an abstract data type called a priority queue. However heap is not a sorted structure. And is useful when it is necessary to repeatedly remove the object with the highest priority.
It can be of two types :
Max-Heap: Key present at the root node must be greatest among rest of all the children nodes. And the same property must be recursively true for all sub-trees in that Binary Tree.
Min-Heap: Key present at root node must be minimum among rest of all the children nodes. And the same property must be recursively true for all sub-trees in that Binary Tree.
Follow us on Instagram @programmersdoor
Join us on Telegram @programmersdoor
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed.
Follow Programmers Door for more.
Comments