Data Structures & AlgorithmsModerateGATE CS · TCS NQT

Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 36 are inserted in this order into an empty binary search tree. The post-order traversal of the final tree is:

  1. A. 20 35 36 45 40 30 65 60 80 70 50
  2. B. 20 36 35 45 40 30 65 60 80 70 50
  3. C. 20 36 35 40 45 30 60 65 80 70 50
  4. D. 20 36 35 45 40 30 60 65 70 80 50

Correct answer: B. 20 36 35 45 40 30 65 60 80 70 50

35 is the left child of 40 and 36 its right child (36 > 35), so post-order visits 36 before 35. The subtree of 70 gives 65, 60 (65 is 60's right child), 80, 70, and the root 50 is last.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic