23 Lecture
CS301
Midterm & Final Term Short Notes
Single Right Rotation
A single right rotation is a type of operation performed on a binary search tree to balance the tree and ensure efficient search operations. It involves rotating the imbalanced node and its left child to the right, making the left child the new
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is a single right rotation? a) A rotation that balances the right child of a node. b) A rotation that balances the left child of a node. c) A rotation that balances the entire tree. d) A rotation that removes a node from the tree.
Answer: b) A rotation that balances the left child of a node.
- When is a single right rotation used? a) When the imbalance occurs in the immediate left child of a node. b) When the imbalance occurs in the immediate right child of a node. c) When the tree is completely balanced. d) When a new node is inserted into the tree.
Answer: a) When the imbalance occurs in the immediate left child of a node.
- What is the purpose of a single right rotation? a) To maintain the order of the nodes in the subtree. b) To increase the height of the left subtree. c) To decrease the height of the right subtree. d) To remove a node from the tree.
Answer: a) To maintain the order of the nodes in the subtree.
- What is the result of a single right rotation? a) The left child becomes the new root of the subtree. b) The right child becomes the new root of the subtree. c) The subtree becomes completely balanced. d) A node is removed from the tree.
Answer: a) The left child becomes the new root of the subtree.
- What is the maximum number of rotations required to balance a node in a binary search tree? a) One b) Two c) Three d) Four
Answer: b) Two
- What is the purpose of balancing a binary search tree? a) To reduce the height of the tree. b) To increase the height of the tree. c) To ensure efficient search operations. d) To remove nodes from the tree.
Answer: c) To ensure efficient search operations.
- What type of rotation is used when the left child of a node has a right child and the subtree is imbalanced? a) Single left rotation b) Single right rotation c) Double left rotation d) Double right rotation
Answer: c) Double left rotation
- What is the left-right case? a) When the left child of a node has a right child and the subtree is imbalanced. b) When the right child of a node has a left child and the subtree is imbalanced. c) When the left child of a node has a left child and the subtree is imbalanced. d) When the right child of a node has a right child and the subtree is imbalanced.
Answer: a) When the left child of a node has a right child and the subtree is imbalanced.
- What is the right-left case? a) When the right child of a node has a left child and the subtree is imbalanced. b) When the left child of a node has a right child and the subtree is imbalanced. c) When the right child of a node has a right child and the subtree is imbalanced. d) When the left child of a node has a left child and the subtree is imbalanced.
Answer: a) When the right child of a node has a left child and the subtree is imbalanced.
- What is the purpose of double rotations in a binary search tree? a) To remove nodes from the tree. b) To maintain balance when a single rotation is not enough. c) To increase the height of the tree. d) To decrease the height of the tree.
Answer: b) To maintain balance when a single rotation is not enough.
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is single right rotation in AVL tree? A: Single right rotation is a type of operation used to balance an AVL tree in which a node is rotated from its left subtree to its right subtree.
How does single right rotation work? A: Single right rotation works by moving a node from its left subtree to its right subtree, making the right child of the node the new root, and moving the original right child to the left child of the new root.
When is single right rotation needed? A: Single right rotation is needed when the balance factor of a node in the AVL tree is greater than 1 and the left subtree of the node is deeper than its right subtree.
What is the time complexity of single right rotation? A: The time complexity of single right rotation in AVL tree is O(1).
Can a node have both left and right rotations? A: Yes, a node can have both left and right rotations in AVL tree if required to balance the tree.
Does single right rotation change the order of the nodes in AVL tree? A: No, single right rotation does not change the order of the nodes in AVL tree, it only balances the tree.
How is the height of the AVL tree affected by single right rotation? A: The height of the AVL tree is reduced by one level after performing single right rotation.
What is the difference between single left and single right rotation in AVL tree? A: Single left rotation is the mirror image of single right rotation, as it rotates a node from its right subtree to its left subtree to balance the tree.
Can single right rotation be performed on a leaf node? A: No, single right rotation cannot be performed on a leaf node as it requires a node with at least one child.
What are the advantages of using AVL tree over other types of binary trees? A: AVL tree ensures that the height of the tree is always balanced, which results in faster search, insertion, and deletion operations.