in DS edited by
6,072 views
37 votes
37 votes

A Binary Search Tree (BST) stores values in the range $37$ to $573$. Consider the following sequence of keys.

  1. $81, 537, 102, 439, 285, 376, 305$
  2. $52, 97, 121, 195, 242, 381, 472$
  3. $142, 248, 520, 386, 345, 270, 307$
  4. $550, 149, 507, 395, 463, 402, 270$

Which of the following statements is TRUE?

  1. I, II and IV are inorder sequences of three different BSTs
  2. I is a preorder sequence of some BST with $439$ as the root
  3. II is an inorder sequence of some BST where $121$ is the root and $52$ is a leaf
  4. IV is a postorder sequence of some BST with $149$ as the root
in DS edited by
6.1k views

2 Comments

I have one doubt.

As option C is not true in all cases .

Then if one of the option is NONE of these ..Then which one should be marked?
0
0

option C says “inorder sequence of some BST”

2
2

3 Answers

39 votes
39 votes
Best answer
  1. Incorrect because I & IV are not in ascending order.(Inoder sequence of BST is in increasing order)
     
  2. I is a preorder sequence of some BST with $439$ as the root . False because if $439$ is root, it should be first element in preorder.
     
  3. This is correct.
     
  4. IV is a postorder sequence of some BST with $149$ as the root, False because if $149$ is root, it should be last element in postorder
edited by

4 Comments

@Mahima, you are true but in the question all the other options are incorrect and also the question says which of the following is true not "always true"
1
1

@Mahima

II is an inorder sequence of some BST where 121 is the root and 52 is a leaf

some BST means there exists a BST with these properties.

2
2

those who are saying option C is not correct in all the cases…. 

II is an inorder sequence of some BST where 121 is the root and 52 is a leaf.

 

2
2
14 votes
14 votes
it should be C)

Inorder sequences are sorted. In preorder traversal root comes first and in postorder traversal root comes last.

2 Comments

 pls justfy........."where 121 is the root and 52 is a leaf"

3
3
apply AVL rotation and do balance it you will got 52 at the end
1
1
4 votes
4 votes

Answer should be option C

1 comment

from where 142 and 52 coming explain?
0
0
Answer:

Related questions