Q. How many colors are used in a Red-Black tree?
-
A.
One
-
B.
Two
-
C.
Three
-
D.
Four
Solution
A Red-Black tree uses two colors: red and black, to maintain balance and ensure properties.
Correct Answer:
B
— Two
Learn More →
Q. In an AVL tree, what must be done after an insertion if the tree becomes unbalanced?
-
A.
Perform a single rotation
-
B.
Perform a double rotation
-
C.
Rebuild the entire tree
-
D.
Nothing is needed
Solution
After an insertion, if the AVL tree becomes unbalanced, a double rotation may be required to restore balance.
Correct Answer:
B
— Perform a double rotation
Learn More →
Q. What is the time complexity of balancing an AVL tree after a deletion?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Balancing an AVL tree after a deletion operation takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for deleting an element from an AVL tree?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
The worst-case time complexity for deleting an element from an AVL tree is O(log n) due to the need to maintain balance.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following is a property of a Red-Black tree?
-
A.
Every node is red
-
B.
Every path from root to leaf has the same number of black nodes
-
C.
All leaves are red
-
D.
The root must be red
Solution
In a Red-Black tree, every path from the root to the leaves must have the same number of black nodes, ensuring balanced height.
Correct Answer:
B
— Every path from root to leaf has the same number of black nodes
Learn More →
Q. Which property is NOT true for Red-Black Trees?
-
A.
Every node is either red or black
-
B.
The root is always black
-
C.
All leaves are red
-
D.
Red nodes cannot have red children
Solution
In Red-Black Trees, all leaves (NIL nodes) are black, not red.
Correct Answer:
C
— All leaves are red
Learn More →
Showing 1 to 6 of 6 (1 Pages)