Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q711: Which data structure is used to implement a priority queue efficiently?
- A: Stack
- B: Queue
- C: Heap
- D: Linked List
View Answer
C
Q712: What is the time complexity of removing the minimum element from a min-heap?
- A: O(1)
- B: O(log N)
- C: O(N)
- D: O(N log N)
View Answer
B
Q713: What is the key property of disjoint sets?
- A: If A is related to B and B is related to C, then A is related to C
- B: If A is related to B, then B is not related to C
- C: If A is related to B, then A and B have no common elements
- D: If A is related to B, then A and B are disjoint
View Answer
C
Q714: In the context of disjoint sets, what is the purpose of union operations?
- A: To combine two sets into one set
- B: To find if two sets are disjoint
- C: To partition a set into multiple sets
- D: To delete elements from a set
View Answer
A
Q715: What is the use of the `deleteMin` operation in heap data structures?
- A: To find the maximum element
- B: To remove the minimum element
- C: To insert a new element
- D: To build a new heap
View Answer
B
Q716: What does the `full()` method check in the PriorityQueue class?
- A: Whether the heap is full or not
- B: Whether the heap is empty or not
- C: The size of the queue
- D: The maximum capacity of the heap
View Answer
A
Q717: Which sorting algorithm is known for its efficiency due to its use of heaps?
- A: Merge Sort
- B: Quick Sort
- C: Heap Sort
- D: Bubble Sort
View Answer
C
Q718: How is the median of a set of numbers found using heaps?
- A: By finding the smallest number in the heap
- B: By finding the kth smallest number where k = N/2
- C: By sorting the heap and taking the middle element
- D: By performing k deleteMin operations, where k = N/2
View Answer
B
Q719: What does the `partition` function in the quicksort algorithm do?
- A: It divides the array into two parts based on the pivot element
- B: It sorts the array recursively
- C: It selects the pivot element randomly
- D: It inserts elements into a new array
View Answer
C
Q720: How does the quicksort algorithm improve efficiency?
- A: By using a heap to manage elements
- B: By dividing the array and sorting each part recursively
- C: By using a linked list for sorting
- D: By performing insertion sort on each sub-array
View Answer
B