In what kind of test case does insertion sort perform better than selection sort? Clearly describe the test case.
Why does selection sort perform worse than insertion sort in that test case?
I answered the first question like this:
O(n2). When insertion sort is given a list, it takes the current element and inserts it at the appropriate position of the list, adjusting the list every time we insert. It is similar to arranging the cards in a card game.
And the second question:
Because Selection Sort always does n(n-1)/2 comparisons, but in the worst case it will only ever do n-1 swaps.
But I am not sure about my answers, any advice?
[4,3,2,1]
". (I don't know if that's actually true, that's just an example of the format of the answer) – Kevin