Javatpoint Logo
Javatpoint Logo

In-order traversal

Steps

  • Traverse the left sub-tree in in-order
  • Visit the root
  • Traverse the right sub-tree in in-order

Algorithm

  • Step 1: Repeat Steps 2 to 4 while TREE != NULL
  • Step 2: INORDER(TREE -> LEFT)
  • Step 3: Write TREE -> DATA
  • Step 4: INORDER(TREE -> RIGHT)
    [END OF LOOP]
  • Step 5: END

C Function

Example

Traverse the following binary tree by using in-order traversal.


Binary Tree In-order Traversal
  • print the left most node of the left sub-tree i.e. 23.
  • print the root of the left sub-tree i.e. 211.
  • print the right child i.e. 89.
  • print the root node of the tree i.e. 18.
  • Then, move to the right sub-tree of the binary tree and print the left most node i.e. 10.
  • print the root of the right sub-tree i.e. 20.
  • print the right child i.e. 32.
  • hence, the printing sequence will be 23, 211, 89, 18, 10, 20, 32.

Next TopicDoubly Linked List




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA