def parenthesize(tp) """print parenthesized representation of subtree of rooted at ""use of end avoids trailing newline print( element)end if not is leaf( ) first time true for in children( )determine proper separator sep if first time else print(sependany future passes will not be the first first time false parenthesize(tcrecur on child include closing parenthesis printendcode fragment function that prints parenthetic string representation of tree computing disk space in example we considered the use of tree as model for file-system structurewith internal positions representing directories and leaves representing files in factwhen introducing the use of recursion back in we specifically examined the topic of file systems (see section although we did not explicitly model it as tree at that timewe gave an implementation of an algorithm for computing the disk usage (code fragment the recursive computation of disk space is emblematic of postorder traversalas we cannot effectively compute the total space used by directory until after we know the space that is used by its children directories unfortunatelythe formal implementation of postorderas given in code fragment does not suffice for this purpose as it visits the position of directorythere is no easy way to discern which of the previous positions represent children of that directorynor how much recursive disk space was allocated we would like to have mechanism for children to return information to the parent as part of the traversal process custom solution to the disk space problemwith each level of recursion providing return value to the (parentcalleris provided in code fragment def disk space(tp) """return total disk space for subtree of rooted at "" subtotal elementspacespace used at position for in children( )add child' space to subtotal subtotal +disk space(tc return subtotal code fragment recursive computation of disk space for tree we assume that spacemethod of each tree element reports the local space used at that position