Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q271: What is Case I in deleting a node from a Binary Search Tree (BST)?
- A: Node has one child
- B: Node is a leaf node
- C: Node has two children
- D: Node has no children
View Answer
B
Q272: In Case II of deleting a node from a BST, what should you do if the node has one child?
- A: Replace it with the child node
- B: Replace it with the parent node
- C: Replace it with the inorder successor
- D: Do nothing
View Answer
A
Q273: What is the key step in Case III for deleting a node with two children in a BST?
- A: Delete the node directly
- B: Replace with the inorder successor
- C: Replace with the maximum node in the left subtree
- D: Replace with the minimum node in the left subtree
View Answer
B
Q274: What does the findMin method return in a BST?
- A: The maximum node
- B: The root node
- C: The minimum node
- D: The inorder successor
View Answer
C
Q275: What is the role of the remove method in the BST C++ code?
- A: To remove nodes from the tree
- B: To add nodes to the tree
- C: To search for nodes in the tree
- D: To replace nodes in the tree
View Answer
A
Q276: What happens when cmp is less than 0 in the remove method?
- A: The node is in the right subtree
- B: The node is in the left subtree
- C: The node is at the root
- D: The node is not in the tree
View Answer
B
Q277: What is the purpose of the findMin method in BST deletion?
- A: To find the maximum node in the tree
- B: To find the minimum node in the tree
- C: To find the parent of the node
- D: To find the inorder predecessor
View Answer
B
Q278: What should be done if a node with both children is to be deleted in a BST?
- A: Replace it with the parent node
- B: Replace it with the maximum node in the right subtree
- C: Replace it with the inorder successor
- D: Replace it with the root node
View Answer
C
Q279: In the remove method, what happens when the node to be deleted is a leaf node?
- A: It is removed directly
- B: It is replaced with the right child
- C: It is replaced with the left child
- D: It is replaced with the inorder successor
View Answer
A
Q280: How does the findMin method work recursively in a BST?
- A: It searches the right subtree
- B: It searches the left subtree
- C: It searches all nodes
- D: It searches the parent node
View Answer
B