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

Answer: 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.

This question appeared in Past Papers (3 times)
This question appeared in Subjects (3 times)

Install this app on your device for quick access right from your home screen.