algorithm add(value prevalue is the value to add to the heap count is the number of items in the heap postthe value has been added to the heap heap[countvalue count count + minheapify( end add algorithm minheapify( precount is the number of items in the heap heap is the array used to store the heap items postthe heap has preserved min heap ordering count - while and heap[iheap[( )/ swap(heap[ ]heap[( )/ ( )/ end while end minheapify the design of the maxheapify algorithm is very similar to that of the minheapify algorithmthe only difference is that the operator in the second condition of entering the while loop is changed to deletion just as for insertiondeleting an item involves ensuring that heap ordering is preserved the algorithm for deletion has three steps find the index of the value to delete put the last value in the heap at the index location of the item to delete verify heap ordering for each subtree which used to include the value