GATE Computer ScienceModerateGATE CS (PYQ pattern)

The preorder and inorder traversals of a binary tree are 7 3 1 2 5 4 6 and 1 3 2 7 4 5 6 respectively. What is its postorder traversal?

  1. A. 1 3 2 4 6 5 7
  2. B. 1 2 3 6 4 5 7
  3. C. 1 2 3 4 6 5 7
  4. D. 2 1 3 4 5 6 7

Correct answer: C. 1 2 3 4 6 5 7

Root 7; inorder left part 1 3 2 gives subtree rooted at 3 (children 1 and 2), the right part 4 5 6 rooted at 5 (children 4 and 6). Postorder: 1 2 3 4 6 5 7.

More Programming and Data Structures (GATE) questions

Exams that ask this topic