Q. In a Red-Black tree, what property must be maintained after every insertion?
-
A.
The tree must be complete.
-
B.
The tree must be balanced.
-
C.
The root must always be black.
-
D.
All leaves must be red.
Solution
In a Red-Black tree, the root must always be black to maintain the properties of the tree.
Correct Answer:
C
— The root must always be black.
Learn More →
Q. In terms of balancing, how do AVL trees differ from Red-Black trees?
-
A.
AVL trees are less strict
-
B.
Red-Black trees are more strict
-
C.
AVL trees are more strict
-
D.
They are identical
Solution
AVL trees are more strictly balanced than Red-Black trees, which allows for faster lookups.
Correct Answer:
C
— AVL trees are more strict
Learn More →
Q. What is the average time complexity for searching in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The average time complexity for searching in an AVL tree is O(log n) due to its balanced structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the maximum number of nodes in a Red-Black tree of height h?
-
A.
2^h
-
B.
2^(h+1)-1
-
C.
h^2
-
D.
h!
Solution
The maximum number of nodes in a Red-Black tree of height h is 2^(h+1)-1.
Correct Answer:
B
— 2^(h+1)-1
Learn More →
Q. What is the time complexity for deleting an element from an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Deleting an element from an AVL tree also takes O(log n) time, as it may require rebalancing.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of inserting an element into an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Inserting an element into an AVL tree takes O(log n) time due to the need to maintain balance after insertion.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the worst-case time complexity for searching an element in a Red-Black Tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The worst-case time complexity for searching an element in a Red-Black Tree is O(log n) due to its balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which operation is more expensive in terms of time complexity in AVL trees compared to Red-Black trees?
-
A.
Insertion
-
B.
Deletion
-
C.
Searching
-
D.
All of the above
Solution
Deletion in AVL trees can be more expensive due to the need for multiple rotations to maintain balance.
Correct Answer:
B
— Deletion
Learn More →
Q. Which tree structure allows for faster insertion and deletion operations?
-
A.
AVL Tree
-
B.
Red-Black Tree
-
C.
Both are equal
-
D.
Neither
Solution
Red-Black Trees generally allow for faster insertion and deletion operations compared to AVL Trees due to fewer rotations.
Correct Answer:
B
— Red-Black Tree
Learn More →
Showing 1 to 9 of 9 (1 Pages)