Pre-order Traversal: Root, Left, Right!
- Explain pre-order traversal.
This is the strategy for pre-order traversal:
For every node, visit it, then visit its left subtree, then visit its right subtree.

Following the strategy above will generate this sequence:
Explanation
We start with the root, ; then we visit all the nodes in its left subtree. So we move to the subtree rooted at . Next, we visit ; then we visit all the nodes in its left subtree. So, we move to . First, we visit , and then we visit all the nodes in its left subtree. But has no subtree to its left. So we move to visit all the nodes in the right subtree of .

So we move to node . We visit . Then, we must visit all the nodes in the subtree to the left of , but there is none. So, we visit all the nodes to the right subtree of , but there are none. Therefore, we conclude our visit of all the nodes in the right subtree of , and by proxy, our visit to all the nodes in the left subtree of is done too. We must now move to the right subtree of and
Here is a recursive definition of pre-order traversal: for each node, visit it, then recursively perform pre-order traversal of its children (the subtrees rooted at its left and right child, in that order).
Resources
- Pre-order tree traversal in 3 minutes on YouTube.