Q. How many rotations are needed to balance an AVL tree after an insertion?
-
A.
At most one.
-
B.
At most two.
-
C.
At most three.
-
D.
No rotations are needed.
Solution
At most two rotations are needed to balance an AVL tree after an insertion, depending on the case of imbalance.
Correct Answer:
B
— At most two.
Learn More →
Q. What is the color property of a Red-Black tree?
-
A.
Every node is either red or blue.
-
B.
Every node is either red or black.
-
C.
Every node is either black or white.
-
D.
Every node is either green or red.
Solution
In a Red-Black tree, each node is colored either red or black, which helps maintain balance during insertions and deletions.
Correct Answer:
B
— Every node is either red or black.
Learn More →
Q. Which of the following operations is not O(log n) in an AVL tree?
-
A.
Insertion
-
B.
Deletion
-
C.
Searching
-
D.
Traversal
Solution
Traversal of an AVL tree is O(n) because it visits every node, while insertion, deletion, and searching are O(log n).
Correct Answer:
D
— Traversal
Learn More →
Showing 1 to 3 of 3 (1 Pages)