in DS
249 views
1 vote
1 vote

Consider the following nested representation of Binary Trees.

$(ABC)$ indicates $B$ and $C$ are left and right subtrees of node $A$ respectively. Note that $B$ and $C$ may be NULL or further nested.

Which of the following representation is not a valid Binary tree?    
 

  1. (1 2 3)  
  2. (1 (2 3 4) (5 6 7))         
  3. (1 (1 (1 1 1) (1 1 1)) (1 1 1))     
  4. (1 (2 3) 4)
in DS
by
249 views

2 Answers

1 vote
1 vote
in option d we have (2 3).. we do not know which is the middle element and binary tree is not defined for such case in the question.

all other options do not have any such case..

1 comment

as in question it is specified that from ABC, only B or C can be null. Now, in (2,3) 2 is root and 3 can be eithe right child or left child of 2 and other child is null. here nowhere mention that tree must have 2 children, so this also a valid binary tree. may be other issue in D option, but not atleast what you have explained
3
3
0 votes
0 votes

Option D should also be correct as (2 3) means root = 2 , left child= 3 , right child = null so writing (2 3 null) is same as writing (2 3)

Answer:

Related questions