📞 0339-0387701 (WhatsApp) Contact

« Back to Maths MCQs

When in-order traversing a tree resulted in E A C K F H D B G; the preorder traversal would return?

A. FAEKCDHGB ✅
B. FAEKCDBHG
C. EAFKHDCBG
D. FEAKDCHBG

Correct Answer: A. FAEKCDHGB

Explanation

  • E: This is the leftmost node in the in-order sequence. It becomes the root in the preorder traversal.
  • A: The next node after E is its left child. So, A is the left child of E.
  • C: Moving further, C is the right child of A.
  • K: K is the right child of C.
  • F: F is the right child of K.
  • H: H is the right child of F.
  • D: D is the left child of F.
  • B: B is the left child of A.
  • G: Finally, G is the right child of B.
  • Putting it all together, we get the preorder traversal: FAEKCDHGB.