Machine-translated by Google. Questions are authored in English.
Top

Discussion

The post order traversal of a binary tree is DEBFCA. Find out the preorder traversal.

  • A.ABFCDE
  • B.ADBFEC
  • C.ABDECF
  • D.None of the above

Answer: C

The preorder traversal is ABDECF.

In a postorder traversal the root comes last, so DEBFCA has A as the root. The nodes before it split into the left and right subtrees. B comes after D and E and before F and C, so B is the root of the left subtree with D and E as its children, and C is the root of the right subtree with F as its child.

\[ \text{Preorder} = A\,B\,D\,E\,C\,F \]

Option (A), ABFCDE, and option (B), ADBFEC, do not match the shape given by the postorder, and (D) is wrong since ABDECF is among the options.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.