0% found this document useful (0 votes)
5 views

Tree _ DPP 05 (of Lec 06)

The document contains a Data Structure DPP focused on Trees, specifically AVL trees and Binary Search Trees (BST). It includes various types of questions such as NAT, MCQ, and MSQ, along with an answer key and hints for solving the problems. The document is structured to test understanding of tree properties, traversal methods, and heap construction.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Tree _ DPP 05 (of Lec 06)

The document contains a Data Structure DPP focused on Trees, specifically AVL trees and Binary Search Trees (BST). It includes various types of questions such as NAT, MCQ, and MSQ, along with an answer key and hints for solving the problems. The document is structured to test understanding of tree properties, traversal methods, and heap construction.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1

Branch : CSE & IT Batch : Hinglish


Data Structure
Tree DPP 05

[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

Hint & Solutions


1. (20)
The minimum number of nodes in an AVL tree of
height ‘h’ is given by-
n(h) = n(h – 1) + n(h – 2) + 1
n(1) = 1, n(2) = 2, n(3) = 4, n(4) = 7, n(5) = 12,
n(6) = 20

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)

Post order traversal: -


1 4 21 7 25

6. (b, c)
(a)
4

Satisfies max-heap property.


(d)

Not possible defies min-heap property


Not possible defies max-heap property
(b)
7. (0)
Both the statements are CORRECT.

8. (12)
Resultant AVL tree:

Satisfies min-heap property


(c)

Any issue with DPP, please report by clicking here:- https://forms.gle/t2SzQVvQcs638c4r5


For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if

PW Mobile APP: https://smart.link/7wwosivoicgd4

You might also like