Q. What is the worst-case time complexity for inserting an element into a Red-Black tree?
-
A.
O(log n)
-
B.
O(n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The worst-case time complexity for inserting an element into a Red-Black tree is O(log n) due to its balanced structure.
Correct Answer:
A
— O(log n)
Learn More →
Q. Which of the following scenarios is best suited for using a Red-Black tree?
-
A.
When frequent insertions and deletions are required.
-
B.
When memory usage is a critical factor.
-
C.
When the data is static and rarely changes.
-
D.
When the data needs to be sorted frequently.
Solution
Red-Black trees are efficient for scenarios with frequent insertions and deletions due to their balancing properties.
Correct Answer:
A
— When frequent insertions and deletions are required.
Learn More →
Q. Which operation may require rebalancing in an AVL tree?
-
A.
Searching
-
B.
Insertion
-
C.
Traversal
-
D.
Deletion
Solution
Insertion may require rebalancing in an AVL tree if it causes the tree to become unbalanced.
Correct Answer:
B
— Insertion
Learn More →
Q. Which traversal method is commonly used to retrieve elements in sorted order from a binary search tree?
-
A.
Pre-order
-
B.
Post-order
-
C.
In-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree retrieves elements in sorted order.
Correct Answer:
C
— In-order
Learn More →
Showing 1 to 4 of 4 (1 Pages)