36 views
When inorder traversal of a tree is given by OBAXVRZPW, the preorder traversal will yield:

1. XABOVZRWP

2. XABOVZRPW

3. XOBAZRPWV

4. XOBAVRZPW
in DS | 36 views

Inorder : OBAXVRZPW

Preorder : XABOVZRPW

• In every option they have given X as first, so first character X will be the root in preorder.

• so inorder traversal got partitioned like OBA   X   VRZPW.

• Left tree is OBA.

• next in VRZPW right tree, look at preoder traversal, V will be the next root element.

• similarly follow the steps until last element.

by (5 points)
0
How do you come to this perfect conclusion?

I mean there can be many other trees. other options can also be true I guess.
0
After eliminating all the options by applying rules, this is the only pair I got which comes true for both in-order and pre-order, if you can form any other tree, please let me know, I’ll correct it.
0

Kindly look at these other options too, They are also not wrong.

0
Right, I think answer should be should be all of the above.
0
OBA is left of X, okay !

but why not like O right child B, B right child A. then also your tree inorder is OBA