CommerceBinary Search TreesB Tree MCQs
Practice Binary Search TreesB Tree MCQs for competitive exams.
Binary Search TreesB Tree MCQs
Practice questions from this topic.
Consider a situation of writing a binary tree into a file with memory storage efficiency in mind, is array representation of tree is good?
- A. yes because we are overcoming the need of pointers and so space efficiency
- B. yes because array values are indexable
- C. No it is not efficient in case of sparse trees and remaning cases it is fine
- D. No linked list representation of tree is only fine
Correct Answer: C
What is the space complexity of the in-order traversal in the recursive fashion? (d is the tree depth and n is the number of nodes)
- A. O(1)
- B. O(nlogd)
- C. O(logd)
- D. O(d)
Correct Answer: D
In a Binary Search Tree (BST), what does the term "node height" refer to?
- A. The number of edges from the node to its deepest descendant.
- B. The number of nodes in the subtree.
- C. The number of edges from the node to its parent.
- D. The total number of nodes in the tree.
Correct Answer: A
How do you handle duplicate values in a Binary Search Tree (BST) if duplicates are allowed?
- A. Insert duplicates into the right subtree or use a counter at each node.
- B. Insert duplicates into the left subtree.
- C. Store duplicates in a separate data structure.
- D. Ignore duplicate values.
Correct Answer: A
What is the result of an inorder traversal of a Binary Search Tree (BST)?
- A. Nodes are visited in ascending order.
- B. Nodes are visited in descending order.
- C. Nodes are visited in the order of their depth.
- D. Nodes are visited in the order they are inserted.
Correct Answer: A
What is the typical use case for a Binary Search Tree (BST) in computing?
- A. To implement dynamic sets and lookup tables.
- B. To perform sorting operations.
- C. To manage hierarchical data.
- D. To implement priority queues.
Correct Answer: A
In a Binary Search Tree (BST), how can you find the depth of a particular node?
- A. By counting the number of edges from the root to the node.
- B. By counting the number of nodes in the subtree.
- C. By finding the height of the tree.
- D. By counting the number of children of the node.
Correct Answer: A
Which property is true for a Binary Search Tree (BST) that is also a perfect binary tree?
- A. All levels are fully filled, and all leaves are at the same level.
- B. The height of the tree is minimal.
- C. The tree contains only leaf nodes.
- D. All nodes have exactly two children.
Correct Answer: A
What happens if a Binary Search Tree (BST) becomes unbalanced due to insertions or deletions?
- A. Search, insertion, and deletion operations may degrade to O(n) time complexity.
- B. The tree automatically rebalances itself.
- C. The tree converts into a binary heap.
- D. The tree becomes a complete binary tree.
Correct Answer: A
In a BST, how do you identify the maximum value node?
- A. By traversing to the rightmost node from the root.
- B. By traversing to the leftmost node from the root.
- C. By finding the root node.
- D. By searching the entire tree.
Correct Answer: A
What is the minimum number of nodes required to form a Binary Search Tree (BST) of height h?
- A. 2 h - 1
- B. 2 (h+1) - 1
- C. 2 (h)
- D. 2 h
Correct Answer: B
In a Binary Search Tree (BST), which of the following is true for any node's left subtree?
- A. All nodes in the left subtree are smaller than the node itself.
- B. All nodes in the left subtree are larger than the node itself.
- C. The left subtree contains nodes with equal values.
- D. The left subtree is always empty.
Correct Answer: A