Constructing a binary tree from inorder and postorder traversals

  • Thread starter Thread starter Shackman
  • Start date Start date
  • Tags Tags
    Binary Tree
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 15K views
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: