/*internal method that implements two-pass merging firstsibling the root of the conglomerate and is assumed not nullptr *pairnode combinesiblingspairnode *firstsibling iffirstsibling->nextsibling =nullptr return firstsibling/allocate the array static vector treearray )/store the subtrees in an array int numsiblings forfirstsibling !nullptr++numsiblings ifnumsiblings =treearray sizetreearray resizenumsiblings )treearraynumsiblings firstsiblingfirstsibling->prev->nextsibling nullptr/break links firstsibling firstsibling->nextsiblingifnumsiblings =treearray sizetreearray resizenumsiblings )treearraynumsiblings nullptr/combine subtrees two at timegoing left to right int fori numsiblingsi + compareandlinktreearrayi ]treearrayi )int / has the result of last compareandlink /if an odd number of treesget the last one ifj =numsiblings compareandlinktreearrayj ]treearrayj )/now go right to leftmerging last tree with /next to last the result becomes the new last forj > - compareandlinktreearrayj ]treearrayj )return treearray ]figure pairing heapstwo-pass merging