In-Order Traversal in Binary Search Trees

In this lesson, we will cover the second traversal strategy for a Binary Search Tree—In-Order Traversal--and implement it in code by using an example.

In-Order Traversal

In this type, the elements are traversed in a “left-root-right” order: we first visit the left node, then comes the turn of the root, and finally the right child. The following steps are required to perform In-Order Traversal, starting from the root node:

  1. Traverse the left sub-tree of currentNode, recursively using the InOrder() function.

  2. Visit the ​​​current node and read.

  3. Traverse the right sub-tree of currentNode, recursively using the In-Order() function.

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