/*internal method to merge two roots assumes trees are not emptyand ' root contains smallest item *leftistnode merge leftistnode * leftistnode * ifh ->left =nullptr /single node ->left /other fields in already accurate else ->right mergeh ->righth )ifh ->left->npl right->npl swapchildrenh ) ->npl ->right->npl return figure actual routine to merge leftist heaps second pass is made up the heapand child swaps are performed at nodes that violate the leftist heap property in figure there is swap at nodes and and the same tree as before is obtained the nonrecursive version is simpler to visualize but harder to code we leave it to the reader to show that the recursive and nonrecursive procedures do the same thing figure result of merging right paths of and