Back to Practice Data Structures

Sorting Algorithms - Practice MCQs for CCAT

50 Questions Section B: Programming Data Structures

Sorting Algorithms Question Bank for C-CAT

Topic-wise Sorting Algorithms MCQs for CDAC C-CAT preparation with answers and explanations.

Q1.
Which sorting is stable?
AQuick Sort
BMerge Sort
CHeap Sort
DSelection Sort
Show Answer & Explanation

Correct Answer: B - 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
BCounting Sort
CQuick Sort
DRadix Sort
Show Answer & Explanation

Correct Answer: C - Quick Sort

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

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

Correct Answer: A - O(n)

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

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

Correct Answer: B - Merge Sort

Merge Sort and Quick Sort use divide and conquer approach.

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

Correct Answer: A - O(n log n)

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

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

Correct Answer: A - 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
BReverse sorted
CRandom data
DNearly sorted small arrays
Show Answer & Explanation

Correct Answer: D - 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(nk)
CO(n log n)
DO(n)
Show Answer & Explanation

Correct Answer: B - O(nk)

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

Q11.
Which sorting algorithm is adaptive?
AMerge Sort
BInsertion Sort
CHeap Sort
DSelection Sort
Show Answer & Explanation

Correct Answer: B - Insertion Sort

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

Q12.
Shell Sort is an improvement over:
AMerge Sort
BInsertion Sort
CQuick Sort
DHeap Sort
Show Answer & Explanation

Correct Answer: B - Insertion Sort

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

Q13.
Which sort requires no comparisons?
AQuick Sort
BCounting Sort
CMerge Sort
DHeap Sort
Show Answer & Explanation

Correct Answer: B - 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
CRandom only
DMedian-of-three
Show Answer & Explanation

Correct Answer: D - 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)
DO(n + k)
Show Answer & Explanation

Correct Answer: D - 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
BMerge Sort
CHeap Sort
DShell Sort
Show Answer & Explanation

Correct Answer: B - 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:
AMerge and Insertion
BQuick and Heap
CBubble and Selection
DRadix and Counting
Show Answer & Explanation

Correct Answer: A - 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
CInsertion Sort
DMerge Sort
Show Answer & Explanation

Correct Answer: D - 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 has duplicates
CData is sorted
DData is too large for memory
Show Answer & Explanation

Correct Answer: D - Data is too large for memory

External sorting (like external merge sort) is used when data doesn't fit in main memory.

Q21.
What is the worst-case time complexity of Bubble Sort?
AO(n)
BO(n log n)
CO(log n)
DO(n²)
Show Answer & Explanation

Correct Answer: D - O(n²)

Bubble Sort has O(n²) worst-case time complexity, occurring when the array is sorted in reverse order, requiring maximum swaps.

Q22.
Which sorting algorithm repeatedly selects the minimum element and places it at the beginning?
ABubble Sort
BInsertion Sort
CSelection Sort
DMerge Sort
Show Answer & Explanation

Correct Answer: C - Selection Sort

Selection Sort works by repeatedly finding the minimum element from the unsorted portion and placing it at the beginning of the unsorted part.

Q23.
What is the best-case time complexity of Bubble Sort (with early termination optimization)?
AO(n²)
BO(n log n)
CO(1)
DO(n)
Show Answer & Explanation

Correct Answer: D - O(n)

With the optimization of stopping when no swaps occur in a pass, Bubble Sort achieves O(n) best-case time when the array is already sorted.

Q24.
Merge Sort uses which algorithmic paradigm?
ADivide and Conquer
BDynamic Programming
CGreedy
DBacktracking
Show Answer & Explanation

Correct Answer: A - Divide and Conquer

Merge Sort uses Divide and Conquer: it divides the array into halves, recursively sorts them, and merges the sorted halves.

Q25.
What is the time complexity of Merge Sort in all cases?
AO(n)
BO(n²)
CO(n log n)
DO(log n)
Show Answer & Explanation

Correct Answer: C - O(n log n)

Merge Sort has O(n log n) time complexity in best, average, and worst cases. The divide step takes O(log n) levels and merging takes O(n) at each level.

Q26.
What is the space complexity of Merge Sort?
AO(1)
BO(n)
CO(log n)
DO(n²)
Show Answer & Explanation

Correct Answer: B - O(n)

Merge Sort requires O(n) additional space for the temporary arrays used during merging. It is not an in-place sorting algorithm.

Q27.
What is the worst-case time complexity of Quick Sort?
AO(n)
BO(n log n)
CO(n²)
DO(log n)
Show Answer & Explanation

Correct Answer: C - O(n²)

Quick Sort's worst case is O(n²), occurring when the pivot is always the smallest or largest element (e.g., sorted array with first/last element as pivot).

Q28.
What is the average-case time complexity of Quick Sort?
AO(n log n)
BO(n)
CO(n²)
DO(log n)
Show Answer & Explanation

Correct Answer: A - O(n log n)

On average, Quick Sort achieves O(n log n) time complexity when pivots reasonably divide the array into balanced partitions.

Q29.
Which sorting algorithm is NOT stable?
AMerge Sort
BBubble Sort
CInsertion Sort
DSelection Sort
Show Answer & Explanation

Correct Answer: D - Selection Sort

Selection Sort is not stable because it may change the relative order of equal elements during the swap operation.

Q30.
A sorting algorithm is called 'stable' if:
AEqual elements maintain their relative order
BIt uses O(1) extra space
CIt runs in O(n log n) time
DIt never crashes
Show Answer & Explanation

Correct Answer: A - Equal elements maintain their relative order

A stable sorting algorithm preserves the relative order of elements with equal keys, which is important when sorting by multiple criteria.

Q31.
Which sorting algorithm is considered the fastest in practice for most inputs?
ABubble Sort
BSelection Sort
CQuick Sort
DMerge Sort
Show Answer & Explanation

Correct Answer: C - Quick Sort

Quick Sort is generally the fastest in practice due to its good cache performance, low constant factors, and O(n log n) average case.

Q32.
Insertion Sort is most efficient when:
AThe array is nearly sorted
BThe array is randomly ordered
CThe array is sorted in reverse
DThe array has all identical elements
Show Answer & Explanation

Correct Answer: A - The array is nearly sorted

Insertion Sort performs best on nearly sorted arrays, achieving close to O(n) time as very few shifts are needed.

Q33.
What is the worst-case time complexity of Insertion Sort?
AO(n)
BO(n log n)
CO(n²)
DO(log n)
Show Answer & Explanation

Correct Answer: C - O(n²)

Insertion Sort has O(n²) worst-case complexity when the array is sorted in reverse order, requiring maximum shifts for each element.

Q34.
In Quick Sort, the choice of pivot affects:
ASpace complexity only
BStability only
CTime complexity
DNone of the above
Show Answer & Explanation

Correct Answer: C - Time complexity

The pivot choice significantly affects Quick Sort's performance. A bad pivot (extreme element) leads to O(n²), while a good pivot gives O(n log n).

Q35.
Which of the following sorting algorithms is in-place?
AMerge Sort
BCounting Sort
CQuick Sort
DRadix Sort
Show Answer & Explanation

Correct Answer: C - Quick Sort

Quick Sort is an in-place sorting algorithm that uses only O(log n) extra space for the recursion stack. It partitions the array without needing extra arrays.

Q36.
The partition procedure in Quick Sort places the pivot in its:
AFirst position
BLast position
CMiddle position
DCorrect sorted position
Show Answer & Explanation

Correct Answer: D - Correct sorted position

After partitioning, the pivot element is placed in its correct final sorted position, with all smaller elements before it and all larger elements after it.

Q37.
Which sorting algorithm has the same time complexity in best, average, and worst cases?
AMerge Sort
BBubble Sort
CQuick Sort
DInsertion Sort
Show Answer & Explanation

Correct Answer: A - Merge Sort

Merge Sort always has O(n log n) time complexity regardless of the input, as it always divides and merges in the same manner.

Q38.
How many comparisons does Selection Sort make for an array of n elements?
An
Bn - 1
Cn(n-1)/2
Dn log n
Show Answer & Explanation

Correct Answer: C - n(n-1)/2

Selection Sort makes (n-1) + (n-2) + ... + 1 = n(n-1)/2 comparisons regardless of the input order.

Q39.
The recurrence relation for Merge Sort is:
AT(n) = T(n-1) + n
BT(n) = 2T(n/2) + n
CT(n) = T(n/2) + 1
DT(n) = 2T(n-1) + 1
Show Answer & Explanation

Correct Answer: B - T(n) = 2T(n/2) + n

Merge Sort divides the array into two halves (2T(n/2)) and merges them in O(n) time, giving the recurrence T(n) = 2T(n/2) + n.

Q40.
Which sorting algorithm performs the minimum number of swaps?
ASelection Sort
BBubble Sort
CInsertion Sort
DQuick Sort
Show Answer & Explanation

Correct Answer: A - Selection Sort

Selection Sort performs at most n-1 swaps (one per pass), which is the minimum among comparison-based O(n²) sorting algorithms.

Q41.
What is the lower bound for comparison-based sorting algorithms?
AO(n)
BO(n log n)
CO(n²)
DO(log n)
Show Answer & Explanation

Correct Answer: B - O(n log n)

The theoretical lower bound for any comparison-based sorting algorithm is Ω(n log n). No comparison-based sort can do better in the worst case.

Q42.
Bubble Sort is characterized by:
ARepeatedly swapping adjacent elements if they are in wrong order
BInserting each element in its correct position
CSelecting the minimum repeatedly
DDividing the array and merging
Show Answer & Explanation

Correct Answer: A - Repeatedly swapping adjacent elements if they are in wrong order

Bubble Sort works by repeatedly stepping through the list, comparing adjacent elements, and swapping them if they are in the wrong order.

Q43.
In which scenario does Quick Sort perform worst?
ARandom array
BArray with all distinct elements
CAlready sorted array with first element as pivot
DArray with elements in random order
Show Answer & Explanation

Correct Answer: C - Already sorted array with first element as pivot

Quick Sort performs worst on an already sorted array when the first (or last) element is chosen as pivot, creating maximally unbalanced partitions.

Q44.
Which of the following is true about Selection Sort?
AIt always makes O(n²) comparisons
BIts time complexity depends on input order
CIt is stable
DIt requires O(n) extra space
Show Answer & Explanation

Correct Answer: A - It always makes O(n²) comparisons

Selection Sort always makes n(n-1)/2 comparisons regardless of input order, making its time complexity O(n²) in all cases.

Q45.
The best-case time complexity of Insertion Sort is:
AO(n²)
BO(n log n)
CO(1)
DO(n)
Show Answer & Explanation

Correct Answer: D - O(n)

The best case for Insertion Sort is O(n) when the array is already sorted, as each element requires only one comparison and no shifts.

Q46.
Merge Sort is preferred over Quick Sort when:
AMemory is limited
BAverage case performance matters most
CWorst case guarantee is important
DThe array is small
Show Answer & Explanation

Correct Answer: C - Worst case guarantee is important

Merge Sort is preferred when worst-case O(n log n) guarantee is important, as Quick Sort can degrade to O(n²) in the worst case.

Q47.
Which sorting algorithm uses the concept of a 'key' element that divides the array into two parts?
AMerge Sort
BSelection Sort
CBubble Sort
DQuick Sort
Show Answer & Explanation

Correct Answer: D - Quick Sort

Quick Sort uses a 'pivot' (key element) to partition the array into two parts: elements less than the pivot and elements greater than the pivot.

Q48.
How many passes does Bubble Sort need to sort an array of n elements in the worst case?
An - 1
Bn
Cn/2
Dlog n
Show Answer & Explanation

Correct Answer: A - n - 1

Bubble Sort needs n-1 passes in the worst case. After each pass, the largest unsorted element bubbles to its correct position.

Q49.
Which of the following sorting algorithms is adaptive?
ASelection Sort
BInsertion Sort
CMerge Sort
DHeap Sort
Show Answer & Explanation

Correct Answer: B - Insertion Sort

Insertion Sort is adaptive — its performance improves when the input is partially sorted, achieving O(n) for nearly sorted data.

Q50.
What is the space complexity of Quick Sort in the best case?
AO(1)
BO(n log n)
CO(n)
DO(log n)
Show Answer & Explanation

Correct Answer: D - O(log n)

Quick Sort uses O(log n) space in the best/average case for the recursion stack when partitions are balanced. Worst case is O(n) for skewed partitions.

Showing 1-10 of 50 questions