Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Multiple Choice Questions

Q501: What is the purpose of the BuildHeap algorithm?
  • A: To insert elements one by one into the heap
  • B: To build a heap from an unordered array
  • C: To sort the array in ascending order
  • D: To find the maximum element in the heap
View Answer
B

Q502: Which method is used to restore the heap order after deleting the root in a min-heap?
  • A: percolateUp
  • B: percolateDown
  • C: insert
  • D: deleteMin
View Answer
B

Q503: In the BuildHeap algorithm, why do we start with i = N/2?
  • A: To process leaf nodes
  • B: To process the root node
  • C: To process internal nodes
  • D: To start the heap construction from the end
View Answer
C

Q504: What does the percolateDown procedure do?
  • A: Moves larger values up the tree
  • B: Moves smaller values up the tree
  • C: Moves smaller values down the tree
  • D: Moves larger values down the tree
View Answer
C

Q505: What does the decreaseKey method do in a heap?
  • A: Increases the value of the key at position p
  • B: Decreases the value of the key at position p
  • C: Removes the node at position p
  • D: Restores the heap order after insertion
View Answer
B

Q506: What is the role of the increaseKey method in a heap?
  • A: It increases the value of the key at position p
  • B: It decreases the value of the key at position p
  • C: It removes the node at position p
  • D: It restores the heap order after insertion
View Answer
A

Q507: How does the remove method work in a heap?
  • A: It directly removes the node at position p
  • B: It decreases the value of the node to a very small value and then deletes the root
  • C: It increases the value of the node to a very high value and then deletes the root
  • D: It swaps the node with the root and deletes the root
View Answer
B

Q508: What is the primary use of the decreaseKey method in a priority queue?
  • A: To increase the priority of an element
  • B: To decrease the priority of an element
  • C: To remove an element from the priority queue
  • D: To add an element to the priority queue
View Answer
B

Q509: In the provided C++ code, what does the insert method do?
  • A: Inserts an element into the heap while maintaining the heap order
  • B: Deletes the minimum element from the heap
  • C: Gets the minimum element from the heap
  • D: Checks if the heap is full
View Answer
A

Q510: What is the purpose of the percolateDown method in a heap?
  • A: To restore heap order by moving elements down
  • B: To insert elements into the heap
  • C: To build the heap from an array
  • D: To remove the minimum element from the heap
View Answer
A

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now