Data Structures

Sorting Algorithms — Practice MCQs for CCAT

20 Questions Section B: Programming Data Structures

Practice 20 Sorting Algorithms multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Which sorting is stable?
AQuick Sort
BHeap Sort
CMerge Sort
DSelection Sort
Show Answer & Explanation

Correct Answer: C — Merge Sort

Merge Sort is stable - maintains relative order of equal elements.

Q2.
Best case of Bubble Sort:
AO(1)
BO(n)
CO(n log n)
DO(n²)
Show Answer & Explanation

Correct Answer: B — O(n)

With optimization, Bubble Sort is O(n) for already sorted array.

Q3.
Which sort is in-place with O(n log n)?
AMerge Sort
BQuick Sort
CCounting Sort
DRadix Sort
Show Answer & Explanation

Correct Answer: B — Quick Sort

Quick Sort is in-place (O(log n) stack space) with O(n log n) average.

Q4.
Merge Sort space complexity:
AO(1)
BO(n)
CO(log n)
DO(n²)
Show Answer & Explanation

Correct Answer: B — O(n)

Merge Sort needs O(n) auxiliary space for merging.

Q5.
Which sorting uses divide and conquer?
ABubble Sort
BSelection Sort
CMerge Sort
DInsertion Sort
Show Answer & Explanation

Correct Answer: C — Merge Sort

Merge Sort and Quick Sort use divide and conquer approach.

Q6.
Heap Sort time complexity (all cases):
AO(n)
BO(n log n)
CO(n²)
DO(log n)
Show Answer & Explanation

Correct Answer: B — O(n log n)

Heap Sort is O(n log n) in all cases (best, average, worst).

Q7.
Counting Sort is suitable for:
ALarge range of values
BSmall range of integers
CFloating point
DStrings
Show Answer & Explanation

Correct Answer: B — Small range of integers

Counting Sort works best when range of values is small (0 to k).

Q8.
Insertion Sort is efficient for:
ALarge arrays
BNearly sorted small arrays
CRandom data
DReverse sorted
Show Answer & Explanation

Correct Answer: B — Nearly sorted small arrays

Insertion Sort is O(n) for nearly sorted arrays and good for small data.

Q9.
Which sort has worst case O(n²)?
AMerge Sort
BHeap Sort
CQuick Sort
DRadix Sort
Show Answer & Explanation

Correct Answer: C — Quick Sort

Quick Sort has O(n²) worst case when pivot selection is poor.

Q10.
Radix Sort time complexity:
AO(n²)
BO(n log n)
CO(nk)
DO(n)
Show Answer & Explanation

Correct Answer: C — O(nk)

Radix Sort is O(nk) where k is number of digits in max element.

Q11.
Which sorting algorithm is adaptive?
AMerge Sort
BHeap Sort
CInsertion Sort
DSelection Sort
Show Answer & Explanation

Correct Answer: C — Insertion Sort

Insertion Sort is adaptive - it performs better on partially sorted arrays.

Q12.
Shell Sort is an improvement over:
AMerge Sort
BQuick Sort
CInsertion Sort
DHeap Sort
Show Answer & Explanation

Correct Answer: C — Insertion Sort

Shell Sort improves Insertion Sort by comparing elements at gaps, reducing inversions faster.

Q13.
Which sort requires no comparisons?
AQuick Sort
BMerge Sort
CCounting Sort
DHeap Sort
Show Answer & Explanation

Correct Answer: C — Counting Sort

Counting Sort uses counting, not comparisons, making it a non-comparison sort.

Q14.
Best pivot selection for Quick Sort:
AFirst element always
BLast element always
CMedian-of-three
DRandom only
Show Answer & Explanation

Correct Answer: C — Median-of-three

Median-of-three (first, middle, last) helps avoid worst case on sorted/reverse arrays.

Q15.
Bucket Sort average time complexity:
AO(n²)
BO(n log n)
CO(n + k)
DO(n)
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.

Q16.
Which sort is best for linked lists?
AQuick Sort
BHeap Sort
CMerge Sort
DShell Sort
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.

Q17.
Number of swaps in Selection Sort for n elements:
AO(n²)
BO(n)
CO(n log n)
DO(1)
Show Answer & Explanation

Correct Answer: B — O(n)

Selection Sort makes at most n-1 swaps (one per pass), giving O(n) swaps.

Q18.
Tim Sort is a hybrid of:
AQuick and Heap
BMerge and Insertion
CBubble and Selection
DRadix and Counting
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.

Q19.
Which sort has minimum number of comparisons in worst case?
ABubble Sort
BSelection Sort
CMerge Sort
DInsertion Sort
Show Answer & Explanation

Correct Answer: C — Merge Sort

Merge Sort has O(n log n) comparisons even in worst case, optimal for comparison sorts.

Q20.
External sorting is used when:
AData fits in memory
BData is too large for memory
CData is sorted
DData has duplicates
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.