Q. If a binary tree has 'n' nodes, what is the maximum height of the tree?
-
A.
n
-
B.
log n
-
C.
n/2
-
D.
n-1
Solution
The maximum height of a binary tree occurs when the tree is skewed (like a linked list), resulting in a height of n.
Correct Answer:
A
— n
Learn More →
Q. What is the time complexity of a level order traversal of a binary tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Level order traversal visits each node exactly once, resulting in a time complexity of O(n), where n is the number of nodes in the tree.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the time complexity of merging two binary trees?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Merging two binary trees involves visiting each node, resulting in a time complexity of O(n), where n is the total number of nodes in both trees.
Correct Answer:
A
— O(n)
Learn More →
Showing 1 to 3 of 3 (1 Pages)