Data Structures and Algorithms
with Object-Oriented Design Patterns in C++
The third depth-first traversal method is
inorder traversal .
Inorder traversal only makes sense for binary trees.
Whereas preorder traversal visits the root first
and postorder traversal visits the root last,
inorder traversal visits the root in between visiting the left
and right subtrees:
- Traverse the left subtree; and then
- visit the root; and then
- traverse the right subtree.
An inorder traversal of the tree shown in Figure
visits the nodes in the following order:
Copyright © 1997 by Bruno R. Preiss, P.Eng. All rights reserved.