Sanfoundry Tree MCQ
Sanfoundry Tree MCQ
Sanfoundry Tree MCQ
Tree Properties”.
1. The number of edges from the root to the node is called __________ of the tree.
a) Height
b) Depth
c) Length
d) Width
View Answer
Answer: b
Explanation: The number of edges from the root to the node is called depth of the tree.
2. The number of edges from the node to the deepest leaf is called _________ of the tree.
a) Height
b) Depth
c) Length
d) Width
View Answer
Answer: a
Explanation: The number of edges from the node to the deepest leaf is called height of the
tree.
3. What is a full binary tree?
a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level
d) Each node has exactly one or two children
View Answer
Answer: a
Explanation: A full binary tree is a tree in which each node has exactly 0 or 2 children.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate
Now!
advertisement
a)
b)
c)
d)
View Answer
Answer: d
Explanation: Here,
Postorder Traversal: N, P, Q, O, M
Inorder Traversal: N, M, P, O, Q
Root node of tree is the last visiting node in Postorder traversal. Thus, Root Node = ‘M’.
The partial tree constructed is:
The second last node in postorder traversal is O. Thus, node P becomes left child of node
O and node Q becomes right child of node Q. Thus, the final tree is:
12. Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.
a)
b)
c)
d)
View Answer
Answer: b
Explanation: Postorder sequence is 2, 4, 3, 7, 9, 8, 5.
Inorder sequence is the ascending order of nodes in Binary search tree. Thus, Inorder
sequence is 2, 3, 4, 5, 7, 8, 9. The tree constructed using Postorder and Inorder sequence
is
13. Construct a binary tree using inorder and level order traversal given below.
Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
Level Order Traversal: 1, 4, 5, 9, 8, 2, 3
a)
b)
c)
d)
View Answer
Answer: a
Explanation: Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
Level Order Traversal: 1, 4, 5, 9, 8, 2, 3
In level order traversal first node is the root node of the binary tree.
Thus the partially formed tree is:
In level order traversal, the second node is 4. Then, node 3 becomes left child of node 4
and node 2 becomes right child of node 4. Third node of level order traversal is 8. Then,
node 5 becomes left child of node 8 and node 9 becomes right child of node 8. Thus, the
final tree is: