Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Chapter: 21
Q361:
What type of rotation is used to fix case 4?
A. Single right rotation
B. Single left rotation
C. Double right rotation
D. Double left rotation
Correct Answer:
B
Chapter: 21
Q362:
What does an AVL tree ensure about its balance factor?
A. It must be exactly zero for all nodes
B. It must be between 0 and 1 for all nodes
C. It must be between -1 and 1 for all nodes
D. It must be exactly -1 for all nodes
Correct Answer:
C
Chapter: 21
Q363:
How does AVL tree balance differ from Binary Search Tree (BST) balance?
A. AVL tree maintains balance through rotations, BST does not
B. AVL tree requires all nodes to be balanced, BST does not
C. AVL tree can become unbalanced, BST always remains balanced
D. AVL tree ensures root remains the same, BST does not
Correct Answer:
A
Chapter: 21
Q364:
Which case requires a double rotation to balance the AVL tree?
A. Case 1
B. Case 2
C. Case 3
D. Case 4
Correct Answer:
B
Chapter: 21
Q365:
What is the result of inserting node 7 into the AVL tree shown in Fig 21.8?
A. Tree becomes unbalanced
B. Tree becomes perfectly balanced
C. Tree requires no rotations
D. Tree requires a single right rotation
Correct Answer:
B
Chapter: 21
Q366:
Which node will become the new root after rotating the AVL tree in Fig 21.7?
A. Node 2
B. Node 3
C. Node 4
D. Node 5
Correct Answer:
C
Chapter: 21
Q367:
How many levels can a node be searched in an AVL tree of height n?
A. 1.44 log₂n levels
B. 2 log₂n levels
C. 1 log₂n levels
D. log₂n levels
Correct Answer:
A
Chapter: 21
Q368:
What happens to the inorder traversal of an AVL tree after performing rotations?
A. It changes
B. It becomes more balanced
C. It remains the same
D. It becomes less balanced
Correct Answer:
C
Chapter: 21
Q369:
In case 3 of rotation, where is the insertion made?
A. Right subtree of the right child of α
B. Left subtree of the right child of α
C. Right subtree of the left child of α
D. Left subtree of the left child of α
Correct Answer:
B
Chapter: 21
Q370:
What type of insertion requires double rotation in AVL trees?
A. Outside insertion
B. Inside insertion
C. Both types of insertions
D. None of the above
Correct Answer:
B
Chapter: 22
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
Correct Answer:
C
Chapter: 22
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
Correct Answer:
A
Chapter: 22
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
Correct Answer:
C
Chapter: 22
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
Correct Answer:
B
Chapter: 22
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
Correct Answer:
B
Chapter: 22
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
Correct Answer:
B
Chapter: 22
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
Correct Answer:
C
Chapter: 22
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
Correct Answer:
B
Chapter: 22
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
Correct Answer:
A
Chapter: 22
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)
Correct Answer:
A