Logo Data Structures and Algorithms with Object-Oriented Design Patterns in C++
next up previous contents index

Inorder Traversal

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:

  1. Traverse the left subtree; and then
  2. visit the root; and then
  3. traverse the right subtree.
An inorder traversal of the tree shown in Figure gif visits the nodes in the following order:

displaymath63850


next up previous contents index

Bruno Copyright © 1997 by Bruno R. Preiss, P.Eng. All rights reserved.