In this tutorial we are going to learn what do you understand by Heap,minHeap,maxHeap,Heap Sort etc.
What is Heap Data Structure ?
1 : Heap DataStructure is a specialized tree-based abstract data type that satisfies the heap property.By heap property we mean parent and child has ordered relationship and the same ordering applying across the heap.
2 : Heaps can be classified into two types “max heap” or a “min heap”. In a max heap, the keys of parent nodes are always greater than or equal to those of the children and the highest key is in the root node. In a min heap, the keys of parent nodes are less than or equal to those of the children and the lowest key is in the root node.
3 : A heap is not a sorted structure and can be regarded as partially ordered.The highest (or lowest) priority element is always stored at the root
4 : A complete binary heap with N nodes always has log N height.
5 : Heaps are usually implemented in an array (fixed size or dynamic array). After an element is inserted into or deleted from a heap, the heap property is violated and the heap must be balanced by internal operations.
1 : Implement MinHeap
2 : Implement MaxHeap