Input: Tree Traversal Data Output: Build the Tree

Problem:

Ref: Book on Data Structure and Algorithm in C

•From In-order Output to Build the Tree

•Take In-order Traversal Output Data

•And Build the Tree

•Take the middle (N) or so as the root

•Keep going/taking alternate left (nodeLabels) (K D) from there

•Make those also roots/parents (left sub tree)

•The last may be at the last left in this flow

•Then from the last (left last of data)

•Take alternate nodeLabels (P, E) and make them the right child (in left side tree)

•From middle Keep going/taking alternate right node labels (A L)

•Make center/parent/root (right subtree)

•From the end reverse back with the alternate nodes (T F)

•Make these as left children

From Pre-order Tree Traversal Output to Build the Tree
First one becomes the root such as N
Some immediate ones (D G) also becomes parents up until middle (you can choose) – left sub tree parens

Then put some immediate ones (K P) as right children (in left subtree) to come to root

Then take alternate (E F L) to have the parents on the right (Goes Right, right subtree)

come back from right, take remaining (A, T), make them left children (bottom to up direction)

•Input: Post order Tree Traversal data, Output: Tree

•Last one (E) becomes the root

•Some immediate (backward) right ones ones (L A T) up until middle (you can choose)  also becomes parents (downward right side parent)

•– Then put some immediate ones (backward) ( N F ) as left  children to come to root

Then take alternate (K P) to have the parents on the left side of the tree

•Come back from the last, with the remaining ones (G D)

•and make right children (left sub tree)