priority queues (heaps /*inserts xduplicates allowed *void insertconst comparable root mergenew leftistnodex }root )figure insertion routine for leftist heaps as mentioned abovewe can carry out insertions by making the item to be inserted one-node heap and performing merge to perform deleteminwe merely destroy the rootcreating two heapswhich can then be merged thusthe time to perform deletemin is (log nthese two routines are coded in figure and figure finallywe can build leftist heap in (ntime by building binary heap (obviously using linked implementationalthough binary heap is clearly leftistthis is not necessarily the best solutionbecause the heap we obtain is the worst possible leftist heap furthermoretraversing the tree in reverse-level order is not as easy with links the buildheap effect can be obtained by recursively building the left and right subtrees and then percolating the root down the exercises contain an alternative solution /*remove the minimum item throws underflowexception if empty *void deleteminifisemptythrow underflowexception}leftistnode *oldroot rootroot mergeroot->leftroot->right )delete oldroot/*remove the minimum item and place it in minitem throws underflowexception if empty *void deletemincomparable minitem minitem findmin)deletemin)figure deletemin routine for leftist heaps