figure representing book as tree tree traversals now that we have examined the basic functionality of our tree data structureit is time to look at some additional usage patterns for trees these usage patterns can be divided into the three ways that we access the nodes of the tree there are three commonly used patterns to visit all the nodes in tree the difference between these patterns is the order in which each node is visited we call this visitation of the nodes "traversal the three traversals we will look at are called preorderinorderand postorder let' start out by defining these three traversals more carefullythen look at some examples where these patterns are useful preorder in preorder traversalwe visit the root node firstthen recursively do preorder traversal of the left subtreefollowed by recursive preorder traversal of the right subtree inorder in an inorder traversalwe recursively do an inorder traversal on the left subtreevisit the root nodeand finally do recursive inorder traversal of the right subtree postorder in postorder traversalwe recursively do postorder traversal of the left subtree and the right subtree followed by visit to the root node let' look at some examples that illustrate each of these three kinds of traversals first let' look at the preorder traversal as an example of tree to traversewe will represent this book as tree the book is the root of the treeand each is child of the root each section within is child of the and each subsection is child of its sectionand so on figure shows limited version of book with only two note that the traversal algorithm works for trees with any number of childrenbut we will stick with binary trees for now suppose that you wanted to read this book from front to back the preorder traversal gives you exactly that ordering starting at the root of the tree (the book nodewe will follow the preorder traversal instructions we recursively call preorder on the left childin this case we again recursively call preorder on the left child to get to section since section has no childrenwe do not make any additional recursive calls when we are finished with section we move up the tree to at this point we still need to visit the right trees and tree algorithms