method depth written in java the running time of algorithm depth(tvis ( )where denotes the depth of the node in the tree tbecause the algorithm performs constant-time recursive step for each ancestor of thusalgorithm depth (tvruns in (nworst-case timewhere is the total number of nodes of tsince node of may have depth in the worst case although such running time is function of the input sizeit is more accurate to characterize the running time in terms of the parameter since this parameter can be much smaller than height the height of node in tree is also defined recursivelyif is an external nodethen the height of is otherwisethe height of is one plus the maximum height of child of the height of nonempty tree is the height of the root of for examplethe tree of figure has height in additionheight can also be viewed as follows proposition the height of nonempty tree is equal to the maximum depth of an external node of we leave the justification of this fact to an exercise ( - we present here an algorithmheight shown in code fragment and implemented in java in code fragment for computing the height of nonempty tree based on the proposition above and the algorithm depth from code fragment