binary trees there is one less value in the heap since heap requires complete treethere is only one leaf that can be removedthe rightmost node on the lowest level to maintain complete tree and the heap order propertyan extraction requires several steps firstwe copy and save the value from the root nodewhich will be returned after the extraction process has been completed nextthe value from the rightmost node on the lowest level is copied to the root and that leaf node is removed from the treeas shown in figure (athis maintains the heap structure property requiring complete treebut it violates the heap order property since is smaller than its children to restore the heap order propertyvalue has to be sifted-down the tree the sift-down works in the same fashion as the sift-up used with an insertion starting at the root nodethe node' value is compared to its children and swapped with the larger of the two the sift-down is then applied to the node into which the smaller value was copied this process continues until the smaller value is copied into leaf node or node whose children are even smaller parts ( dof figure show the sift-down operation applied to value in the root nodevalue is swapped with then with and finally with resulting in proper heap the code in this method can be placed within the constructor we only used this helper method in order to hide the tree construction details in the initial presentation of the expressiontree class in listing until the actual operation was presented copy to the root (acopy the last item to the root (bsift-downswap and (csift-downswap and (dsift-downswap and figure the steps in restoring max-heap after extracting the root value