Practice 20 Sorting Algorithms multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: C — Merge Sort
Merge Sort is stable - maintains relative order of equal elements.
Show Answer & Explanation
Correct Answer: B — O(n)
With optimization, Bubble Sort is O(n) for already sorted array.
Show Answer & Explanation
Correct Answer: B — Quick Sort
Quick Sort is in-place (O(log n) stack space) with O(n log n) average.
Show Answer & Explanation
Correct Answer: B — O(n)
Merge Sort needs O(n) auxiliary space for merging.
Show Answer & Explanation
Correct Answer: C — Merge Sort
Merge Sort and Quick Sort use divide and conquer approach.
Show Answer & Explanation
Correct Answer: B — O(n log n)
Heap Sort is O(n log n) in all cases (best, average, worst).
Show Answer & Explanation
Correct Answer: B — Small range of integers
Counting Sort works best when range of values is small (0 to k).
Show Answer & Explanation
Correct Answer: B — Nearly sorted small arrays
Insertion Sort is O(n) for nearly sorted arrays and good for small data.
Show Answer & Explanation
Correct Answer: C — Quick Sort
Quick Sort has O(n²) worst case when pivot selection is poor.
Show Answer & Explanation
Correct Answer: C — O(nk)
Radix Sort is O(nk) where k is number of digits in max element.
Show Answer & Explanation
Correct Answer: C — Insertion Sort
Insertion Sort is adaptive - it performs better on partially sorted arrays.
Show Answer & Explanation
Correct Answer: C — Insertion Sort
Shell Sort improves Insertion Sort by comparing elements at gaps, reducing inversions faster.
Show Answer & Explanation
Correct Answer: C — Counting Sort
Counting Sort uses counting, not comparisons, making it a non-comparison sort.
Show Answer & Explanation
Correct Answer: C — Median-of-three
Median-of-three (first, middle, last) helps avoid worst case on sorted/reverse arrays.
Show Answer & Explanation
Correct Answer: C — O(n + k)
Bucket Sort is O(n + k) average where k is number of buckets, assuming uniform distribution.
Show Answer & Explanation
Correct Answer: C — Merge Sort
Merge Sort is ideal for linked lists as it doesn't need random access and works well with sequential data.
Show Answer & Explanation
Correct Answer: B — O(n)
Selection Sort makes at most n-1 swaps (one per pass), giving O(n) swaps.
Show Answer & Explanation
Correct Answer: B — Merge and Insertion
Tim Sort combines Merge Sort with Insertion Sort for small runs, used in Python and Java.
Show Answer & Explanation
Correct Answer: C — Merge Sort
Merge Sort has O(n log n) comparisons even in worst case, optimal for comparison sorts.
Show Answer & Explanation
Correct Answer: B — Data is too large for memory
External sorting (like external merge sort) is used when data doesn't fit in main memory.