Q. In a binary tree, what is the minimum number of nodes required to have a height of h?
A.
h
B.
h + 1
C.
2^h
D.
2^(h+1) - 1
Show solution
Solution
The minimum number of nodes required to have a height of h in a binary tree is h, which occurs in a skewed tree.
Correct Answer:
A
— h
Learn More →
Q. What is the primary advantage of using a binary tree over a linked list for data storage?
A.
Easier to implement
B.
Faster access time for sorted data
C.
Less memory usage
D.
No need for pointers
Show solution
Solution
A binary tree allows for faster access times for sorted data compared to a linked list, especially for search operations.
Correct Answer:
B
— Faster access time for sorted data
Learn More →
Q. What is the primary purpose of a binary tree's post-order traversal?
A.
To evaluate expressions
B.
To print nodes in sorted order
C.
To find the height of the tree
D.
To find the maximum element
Show solution
Solution
Post-order traversal is primarily used to evaluate expressions represented by binary trees, as it processes the left and right children before the parent node.
Correct Answer:
A
— To evaluate expressions
Learn More →
Q. What is the result of a level-order traversal of the following binary tree: 1, 2, 3, 4, 5?
A.
1, 2, 3, 4, 5
B.
1, 3, 2, 5, 4
C.
2, 4, 3, 5, 1
D.
4, 5, 2, 3, 1
Show solution
Solution
Level-order traversal visits nodes level by level from top to bottom, resulting in 1, 2, 3, 4, 5.
Correct Answer:
A
— 1, 2, 3, 4, 5
Learn More →
Q. What is the worst-case time complexity for searching an element in a binary search tree?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
In the worst case, a binary search tree can degenerate into a linked list, leading to a search time complexity of O(n).
Correct Answer:
A
— O(n)
Learn More →
Q. Which of the following is NOT a characteristic of a binary search tree (BST)?
A.
Left subtree contains only nodes with values less than the parent node.
B.
Right subtree contains only nodes with values greater than the parent node.
C.
Both subtrees must be binary trees.
D.
All nodes must have two children.
Show solution
Solution
A binary search tree does not require all nodes to have two children; it can have zero, one, or two children.
Correct Answer:
D
— All nodes must have two children.
Learn More →
Q. Which of the following traversal methods can be used to create a mirror image of a binary tree?
A.
Pre-order
B.
In-order
C.
Post-order
D.
All of the above
Show solution
Solution
Any of the traversal methods (pre-order, in-order, post-order) can be used to create a mirror image of a binary tree.
Correct Answer:
D
— All of the above
Learn More →
Showing 1 to 7 of 7 (1 Pages)