Constructing a binary tree from inorder and postorder traversals

  • Thread starter Thread starter Shackman
  • Start date Start date
  • Tags Tags
    Binary Tree
AI Thread Summary
The discussion focuses on constructing binary trees from given inorder and postorder traversals. The first tree is proposed with E as the root, having left child X and right child N, while X has left child A and right child U, and A has left child M and right child F. The correctness of this tree is questioned, and the user expresses confidence in its accuracy. The second tree is constructed with D as the root, B as the left child, and E as the right child, with further details about the children of B and E. The user seeks validation for both tree constructions.
Shackman
Messages
22
Reaction score
2

Homework Statement


Construct the tree from the following traversals
Preorder: EXAMFUN
Inorder: MAFXUEN

The Attempt at a Solution


E
/ \
X N
/ \
A U
/ \
M F

Correct?

Very difficult to see sorry, but E is root with left child X right child N. X has left child A right child U. A has left child M right child F.
 
Last edited:
Physics news on Phys.org
I am now almost positive the first tree is correct, but what about
Preorder: DBACEGF
Inorder: ABCDEFG

I have: Root is D has left child B right child E. B has left child A right child C. E has left child null right child F. F has left child G right child null.
 
Last edited:

Similar threads

Back
Top