Q. How many rotations are required in the worst case for balancing an AVL tree after an insertion?
Solution
In the worst case, 2 rotations may be required to balance an AVL tree after an insertion.
Correct Answer:
B
— 2
Learn More →
Q. How many rotations are required in the worst case when inserting a node in a Red-Black Tree?
Solution
In the worst case, up to 2 rotations may be required to maintain the properties of a Red-Black Tree after insertion.
Correct Answer:
C
— 2
Learn More →
Q. In a Red-Black Tree, what must be true about the path from the root to any leaf?
-
A.
All paths must have the same number of black nodes.
-
B.
All paths must have the same number of red nodes.
-
C.
All paths must have the same number of total nodes.
-
D.
All paths must alternate colors.
Solution
In a Red-Black Tree, every path from the root to any leaf must have the same number of black nodes to maintain balance.
Correct Answer:
A
— All paths must have the same number of black nodes.
Learn More →
Q. What is the average-case time complexity for searching in a Red-Black Tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The average-case time complexity for searching in a Red-Black Tree is O(log n) due to its balanced structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the primary advantage of using Red-Black Trees over AVL Trees?
-
A.
Faster search times.
-
B.
Less strict balancing, leading to faster insertions and deletions.
-
C.
Easier implementation.
-
D.
Lower memory usage.
Solution
Red-Black Trees allow for less strict balancing, which can lead to faster insertions and deletions compared to AVL Trees.
Correct Answer:
B
— Less strict balancing, leading to faster insertions and deletions.
Learn More →
Q. What is the time complexity for deleting a node in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for deleting a node in an AVL tree is O(log n) as the tree remains balanced after deletion.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for insertion 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 insertion in an AVL tree is O(log n) because the tree remains balanced.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following is a key advantage of AVL trees over Red-Black trees?
-
A.
Faster search times.
-
B.
Easier to implement.
-
C.
Less memory usage.
-
D.
More flexible balancing.
Solution
AVL trees provide faster search times compared to Red-Black trees due to stricter balancing.
Correct Answer:
A
— Faster search times.
Learn More →
Q. Which property is NOT true for AVL trees?
-
A.
They are height-balanced.
-
B.
They allow duplicate values.
-
C.
They require rebalancing after insertions.
-
D.
They can have a maximum height of log n.
Solution
AVL trees do not allow duplicate values; they maintain unique keys.
Correct Answer:
B
— They allow duplicate values.
Learn More →
Showing 1 to 9 of 9 (1 Pages)