Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Multiple Choice Questions

Q341: How does using the const keyword in a class method impact the method's interaction with class members?
  • A: The method can modify class members
  • B: The method cannot modify class members
  • C: The method can only read class members
  • D: The method must be static
View Answer
B

Q342: What is the result of inserting sorted data into a binary search tree?
  • A: The tree becomes balanced
  • B: The tree resembles a linked list
  • C: The tree will be a complete binary tree
  • D: The tree has fewer nodes than expected
View Answer
B

Q343: What is an AVL tree?
  • A: A type of binary tree
  • B: A type of linked list
  • C: A type of array
  • D: A type of stack
View Answer
A

Q344: What is the maximum height difference allowed between the left and right sub-trees in an AVL tree?
  • A: 2
  • B: 1
  • C: 0
  • D: 3
View Answer
B

Q345: In an AVL tree, the balance factor of a node is defined as:
  • A: Height of right subtree minus height of left subtree
  • B: Height of left subtree minus height of right subtree
  • C: Height of left subtree plus height of right subtree
  • D: Height of right subtree plus height of left subtree
View Answer
B

Q346: How many levels are there in a binary tree with height 3?
  • A: 4
  • B: 3
  • C: 5
  • D: 2
View Answer
A

Q347: If a node has a balance factor of 2, what action is typically required?
  • A: No action required
  • B: Right rotation
  • C: Left rotation
  • D: Left-Right rotation
View Answer
B

Q348: When inserting a new node into an AVL tree, what happens if the balance factor of a node is -2?
  • A: Tree becomes unbalanced
  • B: Tree becomes balanced
  • C: Tree remains unchanged
  • D: Requires a left rotation
View Answer
A

Q349: In which scenario does an AVL tree require a left rotation?
  • A: When the right subtree is deeper
  • B: When the left subtree is deeper
  • C: When both subtrees are of equal height
  • D: When there is no subtree
View Answer
B

Q350: Which of the following figures represents an AVL tree?
  • A: Tree with nodes having balance factors outside -1, 0, 1
  • B: Tree where balance factors are -1, 0, 1
  • C: Tree with nodes not having balance factors
  • D: Tree with random heights
View Answer
B

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now