StreakPeaked· Practice

ExamsGATETechnical

The inorder and preorder traversals 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

  1. d e b f g c a
  2. e d b g f c a
  3. e d b f g c a
  4. d e f g b c a

Correct answer: d e b f g c a

Solution

From preorder, the root is a. Splitting inorder around a gives left subtree d b e and right subtree f c g; recursively reconstructing both subtrees yields postorder d e b and f g c. Combining them with the root gives d e b f g c a.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →