Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Multiple Choice Questions

Q331: What is the height of a subtree in an AVL tree defined as?
  • A: The number of nodes in the subtree
  • B: The maximum depth from the root to any leaf
  • C: The number of edges from the root to the leaf
  • D: The sum of the heights of left and right subtrees
View Answer
B

Q332: What does the const keyword at the beginning of the return type indicate?
  • A: The function returns a constant value
  • B: The function returns a constant reference
  • C: The function returns a reference that cannot be modified
  • D: The function returns a constant pointer
View Answer
C

Q333: How does a degenerate binary search tree differ from a balanced binary search tree?
  • A: It is perfectly balanced
  • B: It has a height equal to the number of nodes
  • C: It has no left child for any node
  • D: It has nodes only on one side
View Answer
B

Q334: In a degenerate binary search tree, what happens when searching for a value?
  • A: It is faster than in a balanced tree
  • B: It involves traversing all nodes sequentially
  • C: It uses a binary search algorithm efficiently
  • D: It performs the search in constant time
View Answer
B

Q335: What is a key characteristic of an AVL tree?
  • A: It has nodes with a balance factor of 0 only
  • B: It maintains a balance factor between -1 and 1
  • C: It does not require balancing
  • D: It is always a complete binary tree
View Answer
B

Q336: What is the balance factor of a node in an AVL tree?
  • A: Height of the node
  • B: Difference in heights between left and right subtrees
  • C: Number of children
  • D: Sum of the heights of the left and right subtrees
View Answer
B

Q337: What happens if an AVL tree becomes unbalanced during insertion or deletion?
  • A: The tree remains unbalanced
  • B: The tree is automatically balanced
  • C: The tree is converted into a linked list
  • D: The tree structure is fixed
View Answer
B

Q338: What is the purpose of using a const reference in a function return type?
  • A: To allow the function to modify the returned object
  • B: To prevent modification of the returned object
  • C: To ensure the function returns a copy
  • D: To ensure the returned reference is modifiable
View Answer
B

Q339: Which of the following is a correct characteristic of a degenerate binary search tree?
  • A: It has all nodes with both left and right children
  • B: It looks like a linked list
  • C: It is balanced with left and right subtrees
  • D: It has nodes with varying heights
View Answer
B

Q340: In an AVL tree, if the height difference between left and right subtrees of a node is 2, what is the implication?
  • A: The tree is balanced
  • B: The node needs to be removed
  • C: The tree is unbalanced and needs rotation
  • D: The tree structure is complete
View Answer
C

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now