How to read a comparison properly
The temptation is to run one race, note who won, and file the result away as a ranking. That is the wrong lesson, because the answer changes with the input. Run selection sort against insertion sort on a random array and they look similar. Switch the arrangement to nearly sorted and insertion sort finishes almost immediately while selection sort does exactly the same work as before — it always performs n(n−1)/2 comparisons, no matter what it is given. That difference is what people mean by an adaptive algorithm, and one race demonstrates it better than a paragraph.
Then look at the swap and write rows separately from comparisons. Selection sort makes at most n−1 swaps — the fewest of any comparison sort — while doing the most comparisons. If your data lives somewhere writes are expensive, that trade is the whole decision, and a single “which is faster” question would have hidden it.
Finally, raise the array size in steps: 20, then 50, then 200. Watch how the gap between an O(n²) and an O(n log n) algorithm does not merely grow but accelerates. At 20 elements the difference is unconvincing. At 200 it is roughly an order of magnitude. That acceleration is the entire practical content of asymptotic analysis.
Good pairings to try
- Bubble sort against quick sort — the clearest demonstration of O(n²) versus O(n log n).
- Merge sort against heap sort — same complexity class, very different constant factors and memory.
- Selection sort against insertion sort on a nearly-sorted array — adaptivity, in one run.
- Counting sort against radix sort — what happens when you stop comparing elements altogether.