In-Order Traversal

In this lesson, we will cover In-Order Traversal and implement it in Python.

Introduction #

In In-order traversal, the elements are traversed in “left-root-right” order so they are traversed in order. In other words, elements are printed in sorted ascending order with this traversal. We first visit the left child, then the root/parent node, and then the right child. Here is a high-level description of the in-order traversal algorithm,

  1. Traverse the left sub-tree of the ‘currentNode’ recursively by calling the inOrderPrint() function on it.

  2. Visit the current node and print its value

  3. Traverse the right sub-tree of the ‘currentNode’ recursively by calling the inOrderPrint() function on it.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.