in Others retagged by
4,861 views
4 votes
4 votes

Given a binary tree whose inorder and preorder traversal are given by

Inorder : EICFBGDJHK

Preorder : BCEIFDGHJK

The post order traversal of the above binary tree is

  1. I E F C G J K H D B
  2. I E F C J G K H D B
  3. I E F C G K J H D B
  4. I E F C G J K D B H
in Others retagged by
4.9k views

2 Answers

3 votes
3 votes
Best answer

Preorder - BCEIFDGHJK means root node is B. Inorder - EICFBGDJHK

So search for B in Inorder traversal. Everything to the left of B is left subtree and to the right of B is right subtree in inorder traversal. So we understand that EICF forms the left subtree and GDJHK forms the right subtree of B.

Repeating, this for EICF, we find that C is the root and EI (or IE) forms the left subtree and F forms the right subtree of C. Similarly, for GDJHK, D is the root. G is the left subtree and JHK (or JKH) forms the right subtree.

Therefore, we have the tree as drawn below:

Now finding postorder is very easy. The answer is option (A) IEFCGJKHDB

selected by
2 votes
2 votes

A. I E F C G J K H D B

Related questions