Given inorder and preorder traversals of a tree, how the tree can be re-constructed in non-recursive manner.
For example:
Re-construct the following tree
1
2 3
4 5 6 7
8 9
given
inorder traversal: 4, 2, 5, 8, 1, 6, 3, 9, 7
preorder traversal: 1, 2, 4, 5, 8, 3, 6, 7, 9
Note: There are many references to recursive implementations. For example, one may refer Construct Tree from given Inorder and Preorder traversals. However intent here is to find non-recursive implementation.