The InOrder traversal is one of the three popular ways to traverse a binary tree in Java, other two being preOrder and postOrder. During the inOrder traversal algorithm, left subtree is explored first, followed by root, and finally right subtree. You start traversal from root then goes to left node, then again goes to left node until you reach a leaf node. At that point of time, you print the value of the node or mark it visited and moved to right subtree. Continuing the same algorithm until all nodes of the binary tree are visited. The InOrder traversal is also known as left-node-right traversal or LNR traversal algorithm. Similar to the preOrder algorithm, it is also a depth-first algorithm because it explores the depth of binary tree before exploring siblings. Since it is one of the fundamental binary tree algorithms it's quite popular in programming interviews. They are also the basis to learn more advanced binary tree algorithm, hence every programmer should learn, understand and know how to implement in-order and other traversal algorithms.
Read more »