inside the while loopthe variable index will trickle up the path toward the rootpointing to each node in turn the while loop runs as long as we haven' reached the root (index> and the key (idataof index' parent is less than the new node the body of the while loop executes one step of the trickle-up process it first copies the parent node into indexmoving the node down (this has the effect of moving the "holeupward then it moves index upward by giving it its parent' indexand giving its parent its parent' index public void trickleup(int indexint parent (index- node bottom heaparray[index]whileindex &heaparray[parentidata bottom idata heaparray[indexheaparray[parent]/move node down index parent/move index up parent (parent- /parent <its parent /end while heaparray[indexbottom/end trickleup(finallywhen the loop has exitedthe newly inserted nodewhich has been temporarily stored in bottomis inserted into the cell pointed to by index this is the first location where it' not larger than its parentso inserting it here satisfies the heap condition removal the removal algorithm is also not complicated if we subsume the trickle-down algorithm into its own routine we save the node from the rootcopy the last node (at index currentsize- into the rootand call trickledown(to place this node in its appropriate location public node remove(/delete item with max key /(assumes non-empty listnode root heaparray[ ]/save the root heaparray[ heaparray[--currentsize]/root <last trickledown( )/trickle down the root return root/return removed node /end remove(this method returns the node that was removedthe user of the heap usually needs to process it in some way the trickledown(routine is more complicated than trickleup(because we must determine which of the two children is larger first we save the node at index in variable called top if trickledown(has been called from remove()index is the rootbutas we'll seeit can be called from other routines as well the while loop will run as long as index is not on the bottom row--that isas long as it