In-order

In-order tree traversal visits the left node first, then the root node, and followed by the right node. This continues recursively for each node. The left node stores a smaller value compared to the root node value and right node stores a bigger value than the root node. As a result, when we are applying in-order traversing, we are obtaining a sorted list. That is why, so far, our binary tree traversal was showing a sorted list of numbers. That traversal part is actually the example of an in-order tree traversal. The in-order tree traversal follows these principles:

  1. Traverse the left subtree by recursively calling the in-order function.
  2. Display the data part of the root (or current node).

 

 

  1. Traverse the right subtree by recursively calling the in-order function.

The preceding tree will show A, B, C, D, E, F, G, H, and I as output since it is being traversed in-order.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset