Q. How does an AVL tree maintain balance after an insertion?
-
A.
By performing rotations.
-
B.
By deleting nodes.
-
C.
By increasing the height of the tree.
-
D.
By changing node colors.
Solution
An AVL tree maintains balance after an insertion by performing rotations (single or double) to ensure the height difference property is satisfied.
Correct Answer:
A
— By performing rotations.
Learn More →
Q. What happens to the balance factor of an AVL tree after a right rotation?
-
A.
It increases.
-
B.
It decreases.
-
C.
It remains the same.
-
D.
It becomes zero.
Solution
After a right rotation, the balance factor of the affected nodes decreases, helping to restore balance in the AVL tree.
Correct Answer:
B
— It decreases.
Learn More →
Q. What is the worst-case time complexity for inserting a node in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The worst-case time complexity for inserting a node in an AVL tree is O(log n) due to the tree's balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following operations can cause a violation of the AVL tree property?
-
A.
Insertion of a node.
-
B.
Deletion of a node.
-
C.
Both insertion and deletion.
-
D.
Traversal of the tree.
Solution
Both insertion and deletion can cause the AVL tree to become unbalanced, requiring rebalancing operations.
Correct Answer:
C
— Both insertion and deletion.
Learn More →
Showing 1 to 4 of 4 (1 Pages)