root jj figure the physical implementation of binary tree simply follow the linksonce we reach leaf node we cannot directly access any other node in the tree preorder traversal tree traversal must begin with the root nodesince that is the only access into the tree after visiting the root nodewe can then traverse the nodes in its left subtree followed by the nodes in its right subtree since every node is the root of its own subtreewe can repeat the same process on each noderesulting in recursive solution the base case occurs when null child link is encountered since there will be no subtree to be processed from that link the recursive operation can be viewed graphicallyas illustrated in figure visit the node traverse the left subtree left subtree traverse the right subtree right subtree figure trees are traversed recursively consider the binary tree in figure the dashed lines show the logical order the nodes would be visited during the traversalabdehcfgij this traversal is known as preorder traversal since we first visit the node followed by the subtree traversals the recursive function for preorder traversal of binary tree is rather simpleas shown in listing the subtree argument will either be null reference or reference to the root of subtree in the binary tree if the reference is not nonethe node is first visited and then the two subtrees are traversed by conventionthe left subtree is always visited before the right subtree the subtree argument