in example examines an entire document sequentiallyfrom beginning to end if the external nodes are removed before the traversalthen the traversal examines the table of contents of the document (see figure the preorder traversal is also an efficient way to access all the nodes of tree to justify thislet us consider the running time of the preorder traversal of tree with nodes under the assumption that visiting node takes ( time the analysis of the preorder traversal algorithm is actually similar to that of algorithm height (code fragment )given in section at each node vthe nonrecursive part of the preorder traversal algorithm requires time ( )where is the number of children of thusby proposition the overall running time of the preorder traversal of is (nalgorithm tostringpreorder(tv)implemented in java in code fragment performs preorder printing of the subtree of node of tthat isit performs the preorder traversal of the subtree rooted at and prints the element stored at node when the node is visited recall thatfor an ordered tree tmethod children(vreturns an iterable collection that accesses the children of in order code fragment method tostringpreorder(tvthat performs preorder printing of the elements in the subtree of node of