Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q701: In merge sort, what determines when the recursive calls stop?
- A: The array has only one element
- B: The array is fully sorted
- C: The array is empty
- D: The array size exceeds a threshold
View Answer
A
Q702: How is merge sort implemented in a linked list compared to an array?
- A: The algorithm is the same for both
- B: Merge sort requires additional space for arrays but not for linked lists
- C: Merge sort is faster with arrays
- D: Merge sort requires converting the linked list to an array
View Answer
B
Q703: What is the typical use case for quicksort?
- A: When memory is a concern
- B: When a stable sort is required
- C: When a sorting algorithm with guaranteed O(n log n) performance is needed
- D: When an in-place sort is required
View Answer
D
Q704: How does quicksort ensure the array is eventually sorted?
- A: By repeatedly sorting the entire array
- B: By recursively sorting sub-arrays around a pivot
- C: By using a temporary array to store sorted elements
- D: By performing a linear scan of the array
View Answer
B
Q705: In merge sort, how are elements copied from the temporary array back to the original array?
- A: Using a loop that iterates over the temporary array and original array
- B: By swapping elements directly
- C: By merging in place
- D: Using recursive calls to mergeArrays
View Answer
A
Q706: What is the purpose of the partition function in the quicksort algorithm?
- A: To swap the pivot element with the smallest element
- B: To choose a random pivot element
- C: To divide the array into two parts around the pivot element
- D: To sort the array recursively
View Answer
C
Q707: In the quicksort algorithm, what happens if the size of the array is less than or equal to 1?
- A: The function performs a recursive call
- B: The function performs a partition
- C: The function returns immediately without changes
- D: The function swaps all elements with the pivot
View Answer
D
Q708: Which method is used to place the smallest element of the array at the beginning in quicksort?
- A: partition
- B: insert
- C: sort
- D: merge
View Answer
A
Q709: What is the time complexity of the buildHeap algorithm?
- A: O(N)
- B: O(log N)
- C: O(N log N)
- D: O(1)
View Answer
A
Q710: How does heap sort achieve sorting of elements?
- A: By performing multiple deleteMin operations and recording elements
- B: By applying a partition function repeatedly
- C: By using quicksort on the heap
- D: By iteratively merging sorted arrays
View Answer
A