Implementation Requirements For this project you must write a program that reads
ID: 644274 • Letter: I
Question
Implementation Requirements
For this project you must write a program that reads the preorder and inorder traversals of a
binary tree, constructs an internal linked representation of the tree, and then outputs the
corresponding postorder traversal. You must implement your own binary tree node and tree
classes. You do not need to implement all methods of the tree ADT -- it is sufficient to
implement only the methods that are required to provide the desired output. At least one of
your methods must use recursion.
Program Input
The program should read from the standard input two lines. The first line contains a string
representing the preorder traversal of a binary tree, and the second contains a string
representing the inorder traversal of the same tree. Nodes of the tree are identified by
unique capital letters.
Output
Your program must print a string representing the postorder traversal of the tree followed by
a newline character.
Sample Input #1
DBACEGF
ABCDEFG
Sample Output #1
ACBFGED
Sample Input #2
BCAD
CBAD
Sample Output #2
CDAB
Explanation / Answer
Please rate with 5 stars :)
Let us consider the below traversals:
Inorder sequence: D B E A F C
Preorder sequence: A B D E C F
In a Preorder sequence, leftmost element is the root of the tree. So we know