Which sorting algorithm uses the fewest comparisons?
algorithm, sorting
Solution
Quite Possibly Insertion Sort
Sorting is one of those subjects where, as they say, the devil is in the details. Typically, secondary considerations dominate the performance input parameters.
However, if comparisons are very expensive and if most keys are identical, it is possible that the input could be considered already sorted or already almost sorted.
In that case, what you want is a reasonable algorithm that has the fastest best case, and that would almost certainly be an insertion sort.
Problem
Imagine a case where comparison of two elements is hugely expensive. Which sorting algorithm would you use? Which sorting algorithm uses the fewest comparisons in the average case? What if you can expect a lot of the compared elements to be identical, say in 80% of the comparisons. Does it make a difference?