Tree - DPP 07 (Of Lec 09)
Tree - DPP 07 (Of Lec 09)
[MCQ]
1. Which of the following is/are correct inorder traversal
sequence(s) of binary search tree(s)?
I. 3, 5, 7, 8, 15, 19, 25
II. 5, 8, 9, 12, 10, 15, 25
III. 2, 7, 10, 8, 14, 16, 20
IV. 4, 6, 7, 9 18, 20, 25
(a) I and IV (b) II and III
(c) II and IV (d) II only
[MCQ]
2. What is the worst-case time complexity of inserting n2 [MCQ]
elements into an AVL-tree with n elements initially? 6. A Binary Search Tree (BST) stores values in the range
(a) O(n2) (b) O(n2logn) 37 to 573. Consider the following sequence of keys.
4
(c) O(n ) (d) O(n3)
I. 81, 537, 102, 439, 285, 376, 305
II. 52, 97, 121, 195, 242, 381, 472
[MCQ] III. 142, 248, 520, 386, 345, 270, 307
3. Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are IV. 550, 149, 507, 395, 463, 402, 270
inserted in that order into an initially empty binary
Suppose the BST has been unsuccessfully searched for
search tree. The binary search tree uses the usual
ordering on natural numbers. What is the pre-order key 273. Which all of the above sequences list nodes
traversal sequence of the resultant tree? in the order in which we could have encountered them
(a) 7 5 1 0 3 2 4 6 8 9 in the search?
(b) 0 2 4 3 1 6 5 9 8 7 (a) I and III (b) II and III
(c) 0 1 2 3 4 5 6 7 8 9 (c) III and IV (d) III only
(d) 9 8 6 4 2 3 0 1 5 7
[NAT]
[MCQ] 7. A complete n-ary tree is a tree in which each node has
4. Consider the following statements.
n children or no children. Let I be the number of
S1: The sequence of procedure calls corresponds to a
preorder traversal of the activation tree. internal nodes and L be the number of leaves in a
S2: The sequence of procedure returns corresponds to complete n-ary tree. If L = 41, and I = 10, what is the
a postorder traversal of the activation tree. value of n? _____________.
Which one of the following options is correct?
(a) S1 only (b) S2 only [MCQ]
(c) Both S1 and S2 (d) Neither S1 nor S2 8. A Priority-Queue is implemented as a Max-Heap.
Initially, it has 5 elements. The level-order traversal of
[NAT] the heap is given below: 10, 8, 5, 3, 2. Two new
5. Consider the expression tree shown. Each leaf elements ‘1’ and ‘7’ are inserted in the heap in that
represents a numerical value, which can either be 0 or
order. The level-order traversal of the heap after the
1. Over all possible choices of the values at the leaves,
the maximum possible value of the expression insertion of the elements is:
represented by the tree is ___. (a) 10, 8, 7, 3, 2, 1, 5
(b) 10, 8, 7, 2, 3, 1, 5
(c) 10, 8, 7, 3, 2, 5, 1
(d) None of the above
3
Answer Key
1. (a) 6. (d)
2. (b) 7. (5)
3. (a) 8. (a)
4. (c)
5. (6)
4
1. (a) 6. (d)
The inorder traversal of BST is always in sorted order.
2. (b)
The worst-case time complexity of inserting n2
elements into an AVL-tree with n elements initially is
O(n2logn)
3. (a)
Preorder traversal
7510324689
4. (c)
Both S1 and S2 are CORRECT.
5. (6)
5
8. (a)
7. (5)
L = (N –1) * I + 1
L = 41, I = 10 –
41 = (N –1) * 10 + 1
40
N –1 = =4
10
N=4+1=5