Answer TRUE or FALSE.

If you are given the order of the nodes as visited by a postorder traversal and the order of the nodes as visited by an inorder traversal, do you have enough information to reconstruct the original tree? Assume that the nodes all have unique values.

True
  • True
  • False

Build yourself a small example tree of about 6 or 7 nodes and see what happens.

Consider the example where the root has value A. In the postorder traversal, the left subtree is printed, then the right subtree, then A. In the inorder traversal, the left subtree comes first, then the A, then the right subtree.

From this information, we always know the root, the contents of its left subtree, and the contents of its right subtree.

We can apply this concept recursively to reconstruct the left subtree and the right subtree.