Search⌘ K

In-Order Traversal

Understand how to perform an in-order traversal on binary search trees using C++. This lesson teaches the left-root-right approach that prints nodes in ascending order, reinforcing your grasp of tree operations and recursion.

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 current node recursively by calling the inOrderPrint() function on it. ...