Q. What is the time complexity for deleting an element from a Red-Black tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for deleting an element from a Red-Black tree is O(log n) due to its balanced structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What operation is performed to maintain the balance of an AVL tree after insertion?
-
A.
Rotation
-
B.
Traversal
-
C.
Recoloring
-
D.
Resizing
Solution
Rotations (single or double) are performed to maintain the balance of an AVL tree after insertion.
Correct Answer:
A
— Rotation
Learn More →
Q. Which of the following is true about the height of a Red-Black tree?
-
A.
It can be at most twice the height of an AVL tree.
-
B.
It is always equal to the height of a binary search tree.
-
C.
It is always less than or equal to log(n).
-
D.
It can be greater than the height of an AVL tree.
Solution
The height of a Red-Black tree can be at most twice the height of an AVL tree, making it less balanced.
Correct Answer:
A
— It can be at most twice the height of an AVL tree.
Learn More →
Q. Which operation is used to maintain the balance of an AVL tree after insertion?
-
A.
Recoloring
-
B.
Rotations
-
C.
Resizing
-
D.
Reordering
Solution
Rotations are used to maintain the balance of an AVL tree after insertion or deletion operations.
Correct Answer:
B
— Rotations
Learn More →
Q. Which traversal method is commonly used to print the nodes of a binary search tree in sorted order?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree visits nodes in sorted order.
Correct Answer:
B
— In-order
Learn More →
Showing 1 to 5 of 5 (1 Pages)