Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Constructing a binary tree from inorder and postorder traversals

  1. Feb 26, 2008 #1
    1. The problem statement, all variables and given/known data
    Construct the tree from the following traversals
    Preorder: EXAMFUN
    Inorder: MAFXUEN

    3. 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: Feb 26, 2008
  2. jcsd
  3. Feb 26, 2008 #2
    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: Feb 26, 2008
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook