Sorting algorithms: my comparison table and how I remember each one
I kept mixing sorts up, so I made a memory hook for each.
Bubble sort: big values "bubble" to the end each pass. Stable, in place, O(n²).
Insertion sort: sorting a hand of cards. Great on nearly sorted input.
Selection sort: repeatedly select the smallest remaining. Always O(n²) comparisons, few swaps.
Merge sort: split until trivial, then merge. O(n log n) always, stable, needs extra space.
Quick sort: pick a pivot, partition around it, recurse. Fast in practice, but pivot choice matters.
Heap sort: build a heap and keep removing the top. O(n log n) and in place.
LSD radix sort: sort digit by digit from the least significant. Not comparison based.
For each one I practiced three things: sorting a small array by hand, saying whether it's stable, and naming its worst-case input.
Comments
Practicing "worst-case input" for each sort is great advice. I kept forgetting quick sort's.
The card-hand hook for insertion sort is the one I use too.