Data Structure MCQ - Sorting
This section focuses on the "Sorting" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?
Explanation: No explanation.
2. Which of the following is not a stable sorting algorithm?
Explanation:Selection sort is not a stable sorting algorithm.
3. What is an external sorting algorithm?
Explanation: As the name suggests, external sorting algorithm uses external memory like tape or disk.
4. If the number of records to be sorted is small, then …… sorting can be efficient.
Explanation:Selection sorting can be efficient.
5.Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort.
Explanation:If we use median as a pivot element, then the recurrence for all cases becomes T(n) = 2T(n/2) + O(n) The above recurrence can be solved using Master Method. It falls in case 2 of master method.
6. Which of the following is not an in-place sorting algorithm?
Explanation: Merge sort is not an in-place sorting algorithm.
7. What is the advantage of bubble sort over other sorting techniques?
Explanation: Bubble sort is one of the simplest sorting techniques and perhaps the only advantage it has over other techniques is that it can detect whether the input is already sorted.
8.The complexity of sorting algorithm measures the …… as a function of the number n of items to be sorter.
Explanation:The complexity of sorting algorithm measures the running time as a function of the number n of items to be sorter.
9. Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:
2 5 1 7 9 12 11 10
Which statement is correct?
Explanation:7 and 9 both are at their correct positions (as in a sorted array). Also, all elements on left of 7 and 9 are smaller than 7 and 9 respectively and on right are greater than 7 and 9 respectively.
10.Consider the situation in which assignment operation is very costly. Which of the following sorting algorithm should be performed so that the number of assignment operations is minimized in general?
Also Check :