heaps the trickleup(method has only one major operation in its loopcomparing the key of the new node with the node at the current location the trickledown(method needs two comparisonsone to find the largest child and second to compare this child with the "lastnode they must both copy node from top to bottom or bottom to top to complete the operation heap is special kind of binary treeand as we saw in the number of levels in binary tree equals log ( + )where is the number of nodes the trickleup(and trickledown(routines cycle through their loops - timesso the first takes time proportional to log nand the second somewhat more because of the extra comparison thusthe heap operations we've talked about here all operate in (logntime tree-based heap in the figures in this we've shown heaps as if they were trees because it' easier to visualize them that waybut the implementation has been based on an array howeverit' possible to use an actual tree-based implementation the tree will be binary treebut it won' be search tree becauseas we've seenthe ordering principle is not that strong it will also be complete treewith no missing nodes let' call such tree tree heap one problem with tree heaps is finding the last node you need to find this node to remove the maximum itembecause it' the last node that' inserted in place of the deleted root (and then trickled downyou also need to find the first empty nodebecause that' where you insert new node (and then trickle it upyou can' search for these nodes because you don' know their valuesand anyway it' not search tree howeverthese locations are not hard to find in complete tree if you keep track of the number of nodes in the tree as we saw in the discussion of the huffman tree in you can represent the path from root to leaf as binary numberwith the binary digits indicating the path from each parent to its child for left and for right it turns out there' simple relationship between the number of nodes in the tree and the binary number that codes the path to the last node assume the root is numbered the next row has nodes and the third row has nodes and and so on start with the node number you want to find this will be the last node or the first null node convert the node number to binary for examplesay there are nodes in the tree and you want to find the last node the number decimal is binary remove the initial leaving this is the path from the root to node rightrightleftright the first available null node is which (after removing the initial is binaryrightrightrightleft to carry out the calculationyou can repeatedly use the operator to find the remainder ( or when the node number is divided by and then use the