Constructing a binary tree from inorder and postorder traversals

  • Thread starter Thread starter Shackman
  • Start date Start date
  • Tags Tags
    Binary Tree
Click For Summary
SUMMARY

The discussion focuses on constructing binary trees from given inorder and postorder traversals. The first tree is correctly identified with E as the root, X as the left child, and N as the right child, while A, M, and F are positioned as left and right children accordingly. The second tree is also accurately constructed with D as the root, B and E as its left and right children, respectively, and further child nodes A, C, and F, with G as the right child of F. Both tree structures are confirmed as correct by the participants.

PREREQUISITES
  • Understanding of binary tree structures
  • Knowledge of tree traversal methods (inorder and postorder)
  • Familiarity with tree construction algorithms
  • Basic programming skills for implementing tree structures
NEXT STEPS
  • Study algorithms for constructing binary trees from traversals
  • Learn about tree traversal techniques in depth
  • Implement binary tree construction in a programming language (e.g., Python or Java)
  • Explore advanced tree data structures, such as AVL trees or Red-Black trees
USEFUL FOR

Students in computer science, software developers, and anyone interested in data structures and algorithms, particularly those focusing on binary trees and their traversal methods.

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

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K