Q. How does the time complexity of searching in a Red-Black Tree compare to that in an AVL Tree?
-
A.
Red-Black Tree is faster
-
B.
AVL Tree is faster
-
C.
Both have the same time complexity
-
D.
It depends on the implementation
Solution
Both Red-Black Trees and AVL Trees have a search time complexity of O(log n).
Correct Answer:
C
— Both have the same time complexity
Learn More →
Q. In an AVL tree, what is the balance factor of a node?
-
A.
Height of left subtree - height of right subtree
-
B.
Height of right subtree - height of left subtree
-
C.
Number of nodes in left subtree - number of nodes in right subtree
-
D.
Height of the node itself
Solution
The balance factor of a node in an AVL tree is defined as the height of the left subtree minus the height of the right subtree.
Correct Answer:
A
— Height of left subtree - height of right subtree
Learn More →
Q. What is the maximum number of nodes in an AVL tree of height h?
-
A.
2^h - 1
-
B.
2^(h+1) - 1
-
C.
Fibonacci(h+2) - 1
-
D.
h^2
Solution
The maximum number of nodes in an AVL tree of height h is given by Fibonacci(h+2) - 1.
Correct Answer:
C
— Fibonacci(h+2) - 1
Learn More →
Q. What is the time complexity of balancing an AVL tree after an insertion?
-
A.
O(log n)
-
B.
O(n)
-
C.
O(1)
-
D.
O(n log n)
Solution
Balancing an AVL tree after an insertion takes O(log n) time due to the height of the tree.
Correct Answer:
A
— O(log n)
Learn More →
Q. What is the worst-case time complexity for deleting a node in an AVL tree?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
The worst-case time complexity for deleting a node in an AVL tree is O(log n) due to the need to maintain balance.
Correct Answer:
B
— O(log n)
Learn More →
Q. Which of the following statements is true regarding the balancing of AVL trees?
-
A.
They require fewer rotations than Red-Black trees
-
B.
They are always balanced after every insertion
-
C.
They can become unbalanced after deletion
-
D.
They do not require balancing at all
Solution
AVL trees can become unbalanced after deletion, requiring rebalancing through rotations.
Correct Answer:
C
— They can become unbalanced after deletion
Learn More →
Showing 1 to 6 of 6 (1 Pages)