There are three kinds of tree traversals, namely, Postorder , Preorder and Inorder.
Preorder traversal: Each of nodes is visited before its children are visited; first the root is visited.
Algorithm for pre order traversal is following:
- visit root node
- traverse left sub-tree in preorder
- traverse right sub-tree in preorder