Tree _ DPP 05 (of Lec 06)
Tree _ DPP 05 (of Lec 06)
[NAT] [MSQ]
1. The minimum number of nodes in AVL tree of height 5. Consider the following operations in a BST-
6 is _______. INSERT(23), INSERT(17), INSERT(25), INSERT(4),
(Assume that the height of the root node is 1) INSERT(21), INSERT(1), INSERT(7), DELETE(17),
DELETE(23).
[MCQ] The post-order traversal of the resultant BST is-
2. Consider the following statements: (a) 1, 7, 4, 21, 25
P: An AVL tree is a height-balanced complete binary (b) 1, 4, 7, 25, 21
tree. (c) 1, 4, 21, 7, 25
Q: A heap is necessarily a complete binary tree. (d) None of the above
Which of the following statement(s) is/are
CORRECT? [MSQ]
(a) P only 6. Which of the following sequence(s) of array form a
(b) Q only heap?
(c) Both P and Q (a) 23, 17, 14, 6, 13, 10, 1, 12, 7, 5
(d) Neither P nor Q (b) 1, 5, 10, 6, 7, 12, 13, 14, 17, 23
(c) 23, 17, 14, 7, 13, 10, 1, 5, 6, 12
[NAT] (d) 1, 5, 10, 12, 13, 7, 14, 17, 23, 6
3. The total number of ways in which a max-heap can be
constructed with the keys-7, 6, 1, 4, 5, 2, 3 is ________. [NAT]
7. Consider the following statements:
[MCQ] P: The accepted balanced factor in an AVL tree are –1,
4. Consider the following statements: 0 and +1.
P: If the root node of a BST is deleted, it can be Q: The height of an AVL tree with n nodes is given as
replaced by inorder predecessor. log2n.
Q: If the root node of a BST is deleted, it can be The number of INCORRECT statements is ______.
replaced by preorder successor.
Which of the following is/are CORRECT? [NAT]
(a) P only 8. Construct an AVL tree with the following keys:
(b) Q only 12, 10, 15, 14, 13, 17, 8
(c) Both P and Q The immediate left child key value of the root node of
(d) Neither P nor Q the AVL tree is __________.
2
Answer Key
1. (20) 5. (a, b, c)
2. (b) 6. (b, c)
3. (80) 7. (0)
4. (a) 8. (12)
3
2. (b)
P: INCORRECT. An AVL tree is not necessarily a
complete binary tree.
Post order traversal: -
Q: CORRECT. A heap is necessarily a complete
binary tree. 1 7 4 21 25
3. (80)
T(n) = 1 * ( ) * T(k) * T(n – k – 1)
n –1
k
Here n = 7, k = 3
T(7) = 1 * ( 36 ) * T(3) * T(3)
Now, T(3) = 2
T(7) = 1 * ( 36 ) * 2 * 2 = 80 Post order traversal: -
1 4 7 25 21
4. (a)
If the root node of a BST is deleted, it can be replaced
by inorder predecessor/successor.
5. (a, b, c)
6. (b, c)
(a)
4
8. (12)
Resultant AVL tree: