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.
We'll cover the following
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:
-
Traverse the left sub-tree of currentNode, recursively using the
InOrder()
function. -
Visit the current node and read.
-
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.