Consider this tree:
7
/ \
/ \
/ \
1 9
/ \ / \
0 3 8 10
/ \
2 5
/ \
4 6
Inorder:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Preorder:
7, 1, 0, 3, 2, 5, 4, 6, 9, 8, 10
While doing Inorder traversal, the leftmost left node is first located and the traversal starts from there. But when it comes to Preorder the same logic(as in leftmost middle node) is not applied
In the above tree apart from the root 7, there is 1 and 9 which are both middle nodes. 1 being the leftmost middle node and 9 being the rightmost middle node. Going by the logic applied for above InOrder, the Preorder traversal should have begun from the node 1 which is the leftmost middle node, but its not so, why?
Why is it that in Inorder the traversal starts from the leftmost left node but the PreOrder traversal does not start from leftmost middle node?
Thanks, Chris.