Tree-traversal

Question 1

If the binary tree in figure is traversed in inorder, then the order in which the nodes will be visited is ______

A
4, 1, 6, 7, 3, 2, 5, 8
Question 1 Explanation: 
Inorder traversal is
(Left, Root, Right)
So, the order will be
4, 1, 6, 7, 3, 2, 5, 8
Question 2

Which one of the following binary trees has its inorder and preorder traversals as BCAD  and ABCD, respectively?

A
B
C
D
Question 2 Explanation: 
Inorder traversal is,
Left root right.
Preorder traversal is,
Root left right.
Question 3

The numbers 1, 2, .... n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the root contains p nodes. The first number to be inserted in the tree must be

A
p
B
p + 1
C
n - p
D
n - p + 1
Question 3 Explanation: 
Total element = n
RST contains elements = p
Root contains = 1 element
1st contains = n - (p + 1) element

Root contains the value is n - p.
There are 3 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access