CommerceBinary Search TreesB Tree MCQs
Practice Binary Search TreesB Tree MCQs for competitive exams.
Binary Search TreesB Tree MCQs
Practice questions from this topic.
What is the purpose of the "left rotation" operation in a Binary Search Tree (BST)?
- A. To maintain balance and keep the tree balanced.
- B. To move a node to the right subtree.
- C. To convert a BST into a binary heap.
- D. To find the maximum value node.
Correct Answer: A
When deleting a node from a BST, what should you do if the node to be deleted has two children?
- A. Replace it with its inorder successor or predecessor, then remove the successor or predecessor.
- B. Directly remove the node and replace it with its left child.
- C. Directly remove the node and replace it with its right child.
- D. Replace it with its left child.
Correct Answer: A
Which traversal method is used to obtain the nodes of a BST in the reverse order of their sorted values?
- A. Reverse Inorder
- B. Preorder
- C. Postorder
- D. Level-order
Correct Answer: A
What is the main reason for implementing a Binary Search Tree (BST) as a self-balancing tree?
- A. To maintain O(log n) time complexity for insertions, deletions, and searches.
- B. To ensure the tree is always a complete binary tree.
- C. To allow nodes to be stored in any order.
- D. To minimize memory usage.
Correct Answer: A
In a Binary Search Tree (BST), what is the time complexity of searching for an element in the average case?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n log n)
Correct Answer: B
What is the typical time complexity of accessing an element in a Binary Search Tree (BST) in the best case?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n log n)
Correct Answer: B
How do you find the predecessor of a node in a Binary Search Tree (BST)?
- A. The largest node in the left subtree.
- B. The smallest node in the right subtree.
- C. The smallest node in the left subtree.
- D. The largest node in the right subtree.
Correct Answer: A
Which of the following is a characteristic of a perfectly balanced Binary Search Tree (BST)?
- A. The height of the tree is minimized.
- B. All nodes have exactly two children.
- C. All levels are completely filled except possibly the last.
- D. The left and right subtrees have equal number of nodes.
Correct Answer: A
In a Binary Search Tree (BST), what happens when you perform an inorder traversal?
- A. Nodes are visited in ascending order.
- B. Nodes are visited in descending order.
- C. Nodes are visited in a random order.
- D. Nodes are visited in the order they were inserted.
Correct Answer: A
What is the purpose of the "right rotation" operation in a Binary Search Tree (BST)?
- A. To balance the tree and maintain its properties.
- B. To find the minimum value node.
- C. To delete a node with two children.
- D. To perform a level-order traversal.
Correct Answer: A
In which scenario is a Binary Search Tree (BST) not suitable?
- A. When the data is not sorted.
- B. When frequent insertions and deletions are needed.
- C. When the tree must be balanced at all times.
- D. When elements need to be stored in a priority order.
Correct Answer: A
What property does a Binary Search Tree (BST) ensure for its left and right subtrees?
- A. The left subtree contains nodes with values less than the root, and the right subtree contains nodes with values greater than the root.
- B. The left subtree contains nodes with values greater than the root, and the right subtree contains nodes with values less than the root.
- C. Both subtrees have equal values.
- D. The left subtree is always empty.
Correct Answer: A