edited by
10,852 views
33 votes
33 votes

Consider the following nested representation of binary trees: $(X \ Y \ Z)$ indicates $Y$ and $Z$ are the left and right subtrees, respectively, of node $X$. Note that $Y$ and $Z$ may be $NULL$, or further nested. Which of the following represents a valid binary tree?

  1. $(1 \ 2 \ (4 \ 5 \ 6 \ 7))$
  2. $(1 \ (2 \ 3 \ 4) \ 5 \ 6) \ 7)$
  3. $(1 \ (2 \ 3  \ 4) \ (5 \ 6  \ 7))$
  4. $(1 \ (2 \ 3 \ NULL) \ (4 \ 5))$
edited by

8 Answers

0 votes
0 votes
Main observation -

We can easily see that in XYZ, X = root,  Y = left sub tree,  Z = right sub tree. Therefore inorder form.  

(#($)(%)) --> bracket sequence

Hence option C.
Answer:

Related questions

48 votes
48 votes
4 answers
1
Kathleen asked Sep 14, 2014
17,471 views
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal respectively, of a complete binary tree. Which of the foll...
55 votes
55 votes
8 answers
2
Kathleen asked Sep 14, 2014
9,737 views
An $n \times n$ array $v$ is defined as follows:$v\left[i,j\right] = i - j$ for all $i, j, i \leq n, 1 \leq j \leq n$The sum of the elements of the array $v$ is$0$$n-1$$n...