Heap is a data structure in which array object can be viewed as a nearly complete binary tree. Head data structure is useful for heap-sort and priority queue implementation. There are two kinds of heap-sort:
- Max Heap
- Min Heap
Max Heap: Every node (i) other than root satisfy
A[Parent(i)] >= A[i]
Hence, largest element is at the root.
Min Heap: Every node (i) other than root satisfy
A[Parent(i)] <= A[i]
Hence, smallest element is at the root.