Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Multiple Choice Questions

Q291: In the BinarySearchTree implementation, which method would you use to find the largest item?
  • A: findMin()
  • B: findMax()
  • C: find()
  • D: printTree()
View Answer
B

Q292: What is the output of printTree() after removing all even numbers from a tree containing numbers 0 to 30?
  • A: 0, 2, 4, 6, 8, ..., 30
  • B: 1, 3, 5, 7, 9, ..., 29
  • C: 1, 2, 3, 4, 5, ..., 30
  • D: 2, 4, 6, 8, 10, ..., 30
View Answer
B

Q293: What does the find() method return if the searched element is not found in the tree?
  • A: The element itself
  • B: NULL
  • C: ITEM_NOT_FOUND
  • D: The root of the tree
View Answer
C

Q294: How does the clone() method in BinarySearchTree function?
  • A: It copies the tree structure without elements
  • B: It creates a new tree with the same elements as the original tree
  • C: It deletes the original tree and creates a new one
  • D: It creates a new tree with different elements
View Answer
B

Q295: In the BinarySearchTree implementation, what is the purpose of the elementAt() method?
  • A: To find the largest item in the tree
  • B: To return the element field of a node or ITEM_NOT_FOUND if the node is NULL
  • C: To print the elements of the tree in sorted order
  • D: To remove an element from the tree
View Answer
B

Q296: Which header file is included in the BinarySearchTree.cpp file?
  • A: #include
  • B: #include
  • C: #include "BinarySearchTree.h"
  • D: #include "BinarySearchTree.cpp"
View Answer
C

Q297: What does the symbol & represent when used in front of a variable in C++?
  • A: Address operator
  • B: Bitwise AND operator
  • C: Logical AND operator
  • D: Reference operator
View Answer
A

Q298: In the statement int* ptr = &x;, what does ptr store?
  • A: The value of x
  • B: The address of x
  • C: The type of x
  • D: The reference of x
View Answer
B

Q299: What does the function intMinus1 do to the passed variable?
  • A: Decreases the value by 1 and returns the new value
  • B: Increases the value by 1 and returns the new value
  • C: Decreases the value by 2 and returns the new value
  • D: Increases the value by 2 and returns the new value
View Answer
A

Q300: What is the purpose of using pointers in the function intMinus2?
  • A: To modify the original value of the variable
  • B: To create a new variable
  • C: To copy the value of the variable
  • D: To return a pointer to the variable
View Answer
A

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now