Create a binary tree from the given traversing sequences.
In-order – d b e a f c g
Pre-order – a b d e c f g
Step 1: a is the root node of the binary tree.
Step 2: d, b, and e are on the left side of the a node in the in-order sequence. Hence, d, b, and e are the left subtrees of root a. Also, d is the left subtree of b and e is the right subtree of b.
Step 3: f, c, and g are on the right side of root a in the in-order sequence. Hence, f, c, and g are the right subtrees of root a. Also, f is the left subtree of c and g is the right subtree of c.