Q. How many leaf nodes does a full binary tree with 'n' internal nodes have?
-
A.
n
-
B.
n + 1
-
C.
2n
-
D.
n/2
Solution
A full binary tree with 'n' internal nodes has 'n + 1' leaf nodes.
Correct Answer:
B
— n + 1
Learn More →
Q. What is the maximum depth of a binary tree with 'n' nodes?
-
A.
n
-
B.
log n
-
C.
n/2
-
D.
n - 1
Solution
The maximum depth of a binary tree can be 'n' in the case of a skewed tree.
Correct Answer:
A
— n
Learn More →
Q. What is the primary advantage of using a binary tree over an array for dynamic data storage?
-
A.
Faster access
-
B.
Dynamic size
-
C.
Less memory usage
-
D.
Easier sorting
Solution
Binary trees can grow and shrink dynamically, unlike arrays which have a fixed size.
Correct Answer:
B
— Dynamic size
Learn More →
Q. What is the result of a post-order traversal of a binary tree?
-
A.
Root, Left, Right
-
B.
Left, Right, Root
-
C.
Right, Left, Root
-
D.
Left, Root, Right
Solution
In post-order traversal, the nodes are visited in the order: Left, Right, Root.
Correct Answer:
B
— Left, Right, Root
Learn More →
Q. What is the space complexity of a recursive in-order traversal of a binary tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(1)
-
D.
O(n log n)
Solution
The space complexity is O(h) where h is the height of the tree, which is O(log n) for balanced trees.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of finding the height of a binary tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The height of a binary tree can be found by traversing all its nodes, which takes O(n) time.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the worst-case time complexity of searching for an element in a binary search tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
In the worst case, the time complexity for searching in a binary search tree is O(n), which occurs when the tree is skewed.
Correct Answer:
A
— O(n)
Learn More →
Q. Which traversal method is best for copying a binary tree?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
Pre-order traversal is best for copying a binary tree as it visits the root before its children.
Correct Answer:
A
— Pre-order
Learn More →
Q. Which traversal method would you use to get the nodes of a binary tree in non-decreasing order?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In-order traversal of a binary search tree gives the nodes in non-decreasing order.
Correct Answer:
B
— In-order
Learn More →
Q. Which traversal technique is best suited for printing the nodes of a binary tree level by level?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
Level-order traversal is specifically designed to print the nodes of a binary tree level by level.
Correct Answer:
D
— Level-order
Learn More →
Showing 1 to 10 of 10 (1 Pages)