Awesome q2a theme
0 votes
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 by (5 points) | 36 views

1 Answer

0 votes

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
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
8,437 questions
2,714 answers
13,238 comments
95,460 users