20 Lecture
CS301
Midterm & Final Term Short Notes
AVL Tree
AVL Tree is a self-balancing binary search tree where the difference between the height of the left and right subtrees cannot be more than one for all nodes. It provides faster operations for search, insertion, and deletion compared to other sel
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is AVL Tree? a) Binary Tree b) Self-balancing Binary Search Tree c) Hash Tree d) None of the above
Answer: b) Self-balancing Binary Search Tree
- In AVL Tree, what is the maximum difference between the height of the left and right subtrees? a) 1 b) 2 c) 3 d) 4
Answer: a) 1
- What is the time complexity of search operation in AVL Tree? a) O(log n) b) O(n) c) O(n log n) d) O(1)
Answer: a) O(log n)
- In AVL Tree, what operation is performed to balance the tree? a) Rotation b) Inversion c) Deletion d) None of the above
Answer: a) Rotation
- What is the worst-case time complexity of insertion operation in AVL Tree? a) O(log n) b) O(n) c) O(n log n) d) O(1)
Answer: a) O(log n)
- What is the height of an AVL Tree with n nodes in the worst-case scenario? a) log(n) b) log(n) + 1 c) 2log(n) d) 2log(n) + 1
Answer: b) log(n) + 1
- Which of the following statements is true about AVL Tree? a) AVL Tree is a balanced binary search tree b) AVL Tree is an unbalanced binary search tree c) AVL Tree is a type of heap data structure d) AVL Tree is a type of graph data structure
Answer: a) AVL Tree is a balanced binary search tree
- What is the time complexity of deletion operation in AVL Tree? a) O(log n) b) O(n) c) O(n log n) d) O(1)
Answer: a) O(log n)
- Which of the following is not a balancing rule in AVL Tree? a) Right-Right (RR) b) Left-Right (LR) c) Left-Left (LL) d) Right-Left (RL)
Answer: d) Right-Left (RL)
- Can AVL Tree have duplicate keys? a) Yes b) No
Answer: b) No
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is AVL Tree and what is its purpose? Answer: AVL Tree is a self-balancing binary search tree where the difference between the height of the left and right subtrees cannot be more than one for all nodes. Its purpose is to provide faster operations for search, insertion, and deletion compared to other self-balancing trees.
What is the difference between AVL Tree and Red-Black Tree? Answer: Both AVL Tree and Red-Black Tree are self-balancing binary search trees. The main difference between them is that AVL Tree guarantees that the difference between the heights of left and right subtrees is at most one, whereas Red-Black Tree guarantees that the longest path from the root to a leaf is no more than twice as long as the shortest path.
How does rotation help in balancing the AVL Tree? Answer: Rotation is the operation performed to balance the AVL Tree. It involves changing the structure of the tree by rotating a node to a new position, which helps to maintain the balance of the tree by keeping the height difference of the left and right subtrees at most one.
What is the height of an AVL Tree with one node? Answer: The height of an AVL Tree with one node is 0.
Can AVL Tree have duplicate keys? Answer: No, AVL Tree cannot have duplicate keys.
What is the time complexity of search operation in AVL Tree? Answer: The time complexity of search operation in AVL Tree is O(log n).
What is the worst-case time complexity of insertion operation in AVL Tree? Answer: The worst-case time complexity of insertion operation in AVL Tree is O(log n).
How does AVL Tree maintain balance after a node is inserted or deleted? Answer: AVL Tree maintains balance by performing rotations after a node is inserted or deleted to ensure that the height difference of the left and right subtrees is at most one.
What is the height of a perfectly balanced AVL Tree with 15 nodes? Answer: The height of a perfectly balanced AVL Tree with 15 nodes is 3.
What is the purpose of AVL Tree being self-balancing? Answer: The purpose of AVL Tree being self-balancing is to ensure that the worst-case time complexity of operations like search, insertion, and deletion is O(log n), which is much faster than other non-balanced binary search trees.