Consider the following array. Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?
View worked solution
Answer: C
The given array is already sorted in ascending order:
Let us analyze the number of element comparisons required by each sorting algorithm on an already sorted array of size :
- Insertion Sort:
For an already sorted array, each element from index to is compared exactly once with its immediate predecessor to confirm its correct position. - Selection Sort:
Selection sort always performs the same number of comparisons regardless of the initial order of the array. - Mergesort:
Mergesort uses a divide-and-conquer approach. For , the array is split into subarrays and merged. In the best-case merging scenario (which occurs here), the number of comparisons is: - Quicksort (with last element as pivot):
Since the array is already sorted, choosing the last element as the pivot always results in the most unbalanced partitions (worst-case behavior).
Comparing the results, Insertion Sort requires the least number of comparisons ().
Free practice · Your answers on this page are not saved.
