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
  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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

  1. 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.

  1. 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

  1. 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.

  1. 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.

  1. 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
  1. 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.

  2. 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.

  3. 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.

  4. What is the time complexity of single right rotation? A: The time complexity of single right rotation in AVL tree is O(1).

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

Single right rotation is a balancing operation used in AVL trees to maintain a balance between the height of the left and right subtrees. The operation is performed on a node that violates the AVL tree property, which states that the difference in height between the left and right subtrees of any node should be at most one. During the single right rotation operation, a node is rotated from its left subtree to its right subtree. The right child of the node becomes the new root, and the original right child is moved to the left child of the new root. The rotation can be visualized as moving the node one level down and one level to the right in the tree. Single right rotation is required when the balance factor of a node is greater than one, and the left subtree is deeper than the right subtree. The balance factor of a node is calculated as the difference in height between its left and right subtrees. The time complexity of the single right rotation operation is O(1), as it involves only a constant number of pointer manipulations. The operation does not change the order of the nodes in the AVL tree, only their positions. Single right rotation reduces the height of the AVL tree by one level and maintains the AVL tree property. If the single right rotation is not sufficient to balance the tree, additional rotations may be required. In conclusion, single right rotation is an important operation in AVL trees that ensures that the tree remains balanced and provides faster search, insertion, and deletion operations. It is a simple yet effective technique that can be used to balance the height of the left and right subtrees of a node.