The simplest case is:
A A
/ and \
B B
both with preorder(and level-order) AB and postorder BA
On 2010-4-9 1:23, Himanshu Aggarwal wrote:
For a binary tree , if we are given an inorder traversal and a
preorder/postorder/level-order traversal, we can always reconstruct
back the binary tree. This technique can be used to save and restore
the binary tree efficiently.
I have read that it is necessary to have an inorder traversal to
reconstruct the tree. i.e. if we are given a preorder and a postorder
traversal, the binary tree can not be reconstructed.
Can someone help me in understanding why this is so? i.e. why is
inorder traversal a mandatory requirement. Why can not we reconstruct
the tree with a given preorder and a postorder
Thanks to everyone for their suggestions and replies.
~Himanshu Aggarwal
--
You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google Groups "Algorithm
Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.