Heap Heap is a special type binary tree where every node P is larger than its parent nodes. This is called max heap. In min heap, every node is smaller than its parent In case of max heap, the largest element is always available at the root of the tree. In min heap, the smallest element is at the root of the tree. A heap which is a complete binary tree is called binary heap. A complete binary tree is the one where each level of the tree is completely filled except for last level, which is filled from left to right. Array implementation of binary heap Because binary heap is a complete binary tree, it will be efficient store its elements in an array. Such an array will have index of parent and its children as follows. For every node with index i, the left child is at index 2i+1 and right child is at index 2i+2 In the diagram, a binary heap implemented using an array is shown. The indices are written next to each node. Heapify The process of rearranging the elements to maintain...