1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Constructing a binary tree from inorder and postorder traversals
  1. Binary trees (Replies: 1)

  2. Binary Search tree (Replies: 5)

Loading...