0
3.4kviews
Construct the binary tree for the inorder and post order traversal sequence

Mumbai University > Information Technology > Sem 3 > Data structure and algorithm analysis

Marks: 10M

Year: May 2016

1 Answer
0
111views

In order: “INFORMATION”

Post Oder: “INOFMAINOTR”

steps to follow:

  1. mark the last element of the post order result as it is the root element.
  2. Mark the root element in inorder result.
  3. Root element will divide the inorder result into left subtree and right subtree.
  4. Draw the tree
  5. Repeat the steps till you get the binary tree.

enter image description here

enter image description here

First mark the root element. The root element is always the last element in the POST ORDER sequence. In this case, it is R.

Now, mark R as root in the INORDER sequence, once you do that you will get the left subtree and right subtree.

In order: INFORMATION (left sub tree-> INFO & right subtree -> MATION)

Post order: INOFMAINOTR

// constructing binary tree

enter image description here

Please log in to add an answer.