Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q371: What is the primary purpose of performing rotations in an AVL tree?
- A: To increase the height of the tree
- B: To decrease the height of the tree
- C: To balance the tree
- D: To reorder the elements
View Answer
C
Q372: In which case is a single rotation successful in balancing an AVL tree?
- A: Case-1 and Case-2
- B: Case-2 and Case-3
- C: Case-3 and Case-4
- D: Case-1 and Case-4
View Answer
A
Q373: Which of the following scenarios requires a double rotation to balance an AVL tree?
- A: Single right rotation works
- B: Single left rotation works
- C: Left-right or right-left rotation required
- D: No rotation is required
View Answer
C
Q374: What is the first step in a left-right double rotation?
- A: Perform a right rotation
- B: Perform a left rotation
- C: Perform a single right rotation
- D: Perform a single left rotation
View Answer
B
Q375: What will be the final root after performing a left-right double rotation to fix Case 2?
- A: The left child of the original root
- B: The right child of the original root
- C: The middle child of the original root
- D: The original left-right node
View Answer
B
Q376: What does the avlInsert function do if the new node's value is less than the root's value?
- A: Inserts the node in the right subtree
- B: Inserts the node in the left subtree
- C: Deletes the node from the tree
- D: Updates the height of the root
View Answer
B
Q377: In the C++ code for avlInsert, what happens if the height difference between the left and right subtree is 2?
- A: The tree is balanced without further changes
- B: A single rotation is performed
- C: A double rotation is performed
- D: The tree is immediately deleted
View Answer
C
Q378: After performing a right rotation, which node becomes the new root in the right-left double rotation?
- A: The original left child
- B: The original right child
- C: The node that was previously the right child
- D: The node that was previously the left child
View Answer
B
Q379: What will the inorder traversal of an AVL tree look like after applying necessary rotations?
- A: The same as the original inorder traversal
- B: Completely different from the original traversal
- C: The reverse of the original inorder traversal
- D: An unsorted list of nodes
View Answer
A
Q380: In the AVL tree example provided, what is the height of the tree with 10 million nodes?
- A: 1.44 log2(10 million)
- B: 2.44 log2(10 million)
- C: 0.44 log2(10 million)
- D: 3.44 log2(10 million)
View Answer
A