Q. How does the height of an AVL tree compare to that of a Red-Black tree?
-
A.
AVL trees are always shorter.
-
B.
Red-Black trees are always shorter.
-
C.
They have the same height.
-
D.
AVL trees are shorter in the worst case.
Solution
AVL trees are more strictly balanced, which can lead to a shorter height compared to Red-Black trees in the worst case.
Correct Answer:
D
— AVL trees are shorter in the worst case.
Learn More →
Q. In a Red-Black tree, what is the maximum number of black nodes on any path from the root to a leaf?
-
A.
1
-
B.
2
-
C.
3
-
D.
It can vary.
Solution
In a Red-Black tree, the number of black nodes can vary, but every path from the root to the leaves must have the same number of black nodes.
Correct Answer:
D
— It can vary.
Learn More →
Q. What is the primary advantage of using a Red-Black tree over an AVL tree?
-
A.
Faster search times.
-
B.
Fewer rotations during insertions and deletions.
-
C.
Easier implementation.
-
D.
More balanced structure.
Solution
Red-Black trees generally require fewer rotations during insertions and deletions compared to AVL trees, making them more efficient in practice.
Correct Answer:
B
— Fewer rotations during insertions and deletions.
Learn More →
Q. Which of the following statements is false regarding AVL trees?
-
A.
They are a type of self-balancing binary search tree.
-
B.
They can become unbalanced after insertion or deletion.
-
C.
They require more rotations than Red-Black trees.
-
D.
They can have duplicate values.
Solution
AVL trees do not allow duplicate values; they maintain a strict binary search tree property.
Correct Answer:
D
— They can have duplicate values.
Learn More →
Q. Which traversal method can be used to obtain a sorted order of elements in a binary search tree?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree yields the elements in sorted order.
Correct Answer:
B
— In-order
Learn More →
Showing 1 to 5 of 5 (1 Pages)