concrete methods implemented in this class def is root(selfp)"""return true if position represents the root of the tree ""return self root= def is leaf(selfp)"""return true if position does not have any children ""return self num children( = def is empty(self)"""return true if the tree is empty ""return len(self= code fragment some concrete methods of our tree abstract base class computing depth and height let be the position of node of tree the depth of is the number of ancestors of pexcluding itself for examplein the tree of figure the node storing international has depth note that this definition implies that the depth of the root of is the depth of can also be recursively defined as followsif is the rootthen the depth of is otherwisethe depth of is one plus the depth of the parent of based on this definitionwe present simplerecursive algorithmdepthin code fragment for computing the depth of position in tree this method calls itself recursively on the parent of pand adds to the value returned def depth(selfp)"""return the number of levels separating position from the root ""if self is root( )return elsereturn self depth(self parent( )code fragment method depth of the tree class the running time of depth(pfor position is ( )where denotes the depth of in the tree because the algorithm performs constant-time recursive step for each ancestor of thusalgorithm depth(pruns in (nworstcase timewhere is the total number of positions of because position of may have depth if all nodes form single branch although such running time is function of the input sizeit is more informative to characterize the running time in terms of the parameter as this parameter may be much smaller than