Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • $\begingroup$ Is there a typo here: "[1,2] preorder, [1,2] post-order has to have 1 at the root, but 2 can be either the left child or the right child. " The post order of such a tree would be [2,1] not [1,2] whether 2 is a left or right child. Also, do you mean if both preorder and postorder are given, we cannot reconstruct the tree, or do you mean if we are given only one of them then we cannot reconstruct the tree? $\endgroup$ Commented Jun 20, 2012 at 14:55
  • $\begingroup$ @CEGRD Indeed, the postorder was a typo. The example shows that you cannot fully reconstruct the tree in this case: you can't know whether 2 is a left child or a right child. This corresponds to the “single subtree” case of the reconstruction algorithm. $\endgroup$ Commented Jun 20, 2012 at 19:55
  • $\begingroup$ how does this change if we know it's a Binary Search Tree? for the simple case in your example ([1,2] preorder, [2,1] post-order) we would be able to determine that the root is 1 and that 2 is the right child (because 2 is greater than 1)... right? $\endgroup$ Commented Mar 18, 2014 at 20:28