What is Heap And its Operations
Heap
               A heap is a specialized tree-based data structure that satisfies the heap property: if B is a child node of A, then key (A) ? key(B). This implies that the element with the greatest key is always in the root node, and so such a heap is sometimes called a max heap. (Alternatively, if the comparison is reversed, the smallest element is always in the root node, which results in a min heap.) This is why heaps are used to implement priority queues. The efficiency of heap operations is crucial in several graph algorithms.

Operations

            The operations commonly performed with a heap are
       
        1)  delete-max or delete-min:   removing the root node of a max- or min-heap, respectively
       
         2) increase-key or decrease-key:   updating a key within a max- or min-heap, respectively
       
         3) insert:   adding a new key to the heap
       
          4) merge:   joining two heaps to form a valid new heap containing all the elements of both.

Prev
Next