Posted on by Kalkicode
Code Binary Tree

# Inorder Tree Traversal of a Binary Tree

There are two standard solution to traversal of binary tree in inorder form. First is recursion and second is iterative approach using stack. In this post view both of solution. Before traversal of tree in in-order form that is important to know about what will be the result of inorder traversal of any tree.

Note that nodes are print from left to right in a sequence. That is also indicates the form of,(L R' R). Here L is for left, (R') for root (current node) and R for right.

## Recursive Solution

That is simplest method to traversal tree using system stack (recursion).

1) In this process start of root node of tree.

2) And check it current node value is NULL or not. When that is not NULL then visit left sub tree (left child node). Again repeat this process until current node are not NULL.

3) When current node is NULL in this case current execution are back to previous recursively function. In this time we are printed this node value and repeted step 4.

4) When we are printed node value, after that visit right child (right subtree) of current node. After that repeat the step of 2 and 3.

Here given code implementation process.

## Iterative Solution

In iterative approach we can solve this problem using stack. Stack are main two operation push() and pop(). When find new binary tree nodes then this element are push to stack and when no new node are found then print top element of stack, and pop() remove to top element.

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

Categories
Relative Post