Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The binary tree with root 10, left child 5, right child 15, and 5 having right child 7, 15 having left child 12, is traversed in post-order (left, right, root). What is the third node visited?

  1. A. 10
  2. B. 7
  3. C. 12
  4. D. 15

Correct answer: C. 12

Post-order is 7, 5, 12, 15, 10, so the third node is 12. In-order (5, 7, 10, 12, 15) gives 10, pre-order (10, 5, 7, 15, 12) gives 7, and level order gives 15.

More Coding Interview Problems questions

Exams that ask this topic