17.4k views
1 vote
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively. The postorder traversal of the binary tree is:

(A) d e b f g c a
(B) e d b g f c a
(C) e d b f g c a
(D) d e f g b c a

User Stebooks
by
3.3k points

2 Answers

4 votes

Answer:

The correct answer to the following question will be Option A (d e b f g c a).

Step-by-step explanation:

In the given question the binary tree is missing, so the question is incomplete. The complete question will be:

a

/ \

b c

/ \ / \

d e f g

Now coming to the answer:

In this tree we are applying the post order algorithm for traversing the tree is given below:

Step 1: Go to the left-subtree.

Step 2: Go to the right-subtree.

Step 3: Print the data.

The root 'a' is follow the algorithm Post order After applying the algorithm it comes to the node 'b', 'b' is also follow the Post order algorithm then it comes to 'd', after applying the algorithm Post order it prints 'd'. Similarly all the node follow the same algorithm .

User Tywanda
by
3.4k points
3 votes

Answer:

Option (A)

Step-by-step explanation:

In the post order traversal, we always print left subtree, then right subtree and then the root of the tree. In preorder traversal, First the root is printed, then, left subtree and at last, right subtree, so, the first element in preorder is the root of the tree and we can find elements of left sub tree from in order as all the elements written left to the root will of left subtree and similarly the right one. This is how repeating it will give the post order traversal.

User Tinou
by
3.2k points