[Math] Insertion Sort algorithm array ordering and comparisons

sorting

I'm trying to figure out different scenarios in which insertion sort will have to make n(n-1)/2 comparisons (the worst case). The obvious case is when it the array is ordered in reverse (decreasing order). However, is it possible to have cases other than the reverse order case where the algorithm will still make the maximum possible number of comparisons?

For example, if we have the numbers 1, 2, and 3 in the array: 3, 2, 1 (worst case). Are there any other possible cases that would require the maximum number of comparisons to sort the array?

Best Answer

Pedantically, if it is in reverse order but you swap the first 2 elements (e.g. 2,3,1) you will also have to do n(n-1) comparisons. There are no other orderings that take this long.