Skip to main content
In Order Traversal In Binary Tree
In Order Traversal In Binary Tree
- Its LNR ordered traversal.
- The order goes this way:
- L: Traverse the left sub tree.
- N: visit the node
- R: Traverse the right sub tree.
- Lets check with an example. Consider the following example.
-
- Traverse the left sub tree of node 1
- Traverse the left sub tree of node 2
- Visit the node 2
- Traverse the right sub tree of node 2
- Visit the node 1
- Traverse the right sub tree of node 1
- Traverse the left subtree of node 3
- Visit the node 3
- Traverse the right sub tree of node 3
- On completing the traversal we get the in order if we follow the bolded nodes.
- In Order: 4 , 2 , 5 , 1 , 6 , 3 , 7
Comments
Post a Comment