-
Consider the following nested representation of binary trees: (XYZ) indicates Y and Z are the left and right sub trees, 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 2 (4 5 6 7))
- (1 (2 3 4) (5 6 )7)
- (1 (2 3 4) (5 6 7))
- (1 (2 3 NULL) (4 5))
- (1 2 (4 5 6 7))
Correct Option: C
(XYZ) indicates that Y is left sub-tree and Z is right subtree. Node is X
As per given in the questions :
(1 (234) (567))
We get, the following tree
1 is the root node
2 and 3 are the non-leaf node
4, 5, 6, 7 are the leaf node which may be null or further nested because in a binary tree every node has 0 or children and not just 1.