Q. In a Red-Black tree, what must be true about the children of a red node?
-
A.
They must be red.
-
B.
They must be black.
-
C.
They can be either color.
-
D.
They must be leaf nodes.
Solution
In a Red-Black tree, the children of a red node must be black to maintain the tree's properties.
Correct Answer:
B
— They must be black.
Learn More →
Q. What happens to the balance factor of an AVL tree after an insertion?
-
A.
It remains unchanged.
-
B.
It can become -2 or 2.
-
C.
It can only be -1, 0, or 1.
-
D.
It is always reset to 0.
Solution
After an insertion, the balance factor of an AVL tree can become -2 or 2, indicating that rebalancing is needed.
Correct Answer:
B
— It can become -2 or 2.
Learn More →
Q. What is the time complexity of inserting an element in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Inserting an element in an AVL tree takes O(log n) time due to the tree's balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following operations is guaranteed to be O(log n) in both AVL and Red-Black trees?
-
A.
Insertion
-
B.
Deletion
-
C.
Searching
-
D.
All of the above
Solution
All of the operations (insertion, deletion, and searching) are guaranteed to be O(log n) in both AVL and Red-Black trees.
Correct Answer:
D
— All of the above
Learn More →
Q. Which rotation is performed when a node is inserted into the left subtree of the left child in an AVL tree?
-
A.
Right Rotation
-
B.
Left Rotation
-
C.
Left-Right Rotation
-
D.
Right-Left Rotation
Solution
A right rotation is performed when a node is inserted into the left subtree of the left child in an AVL tree.
Correct Answer:
A
— Right Rotation
Learn More →
Showing 1 to 5 of 5 (1 Pages)