Glossary
Canonical terms for this subject. Every lesson uses these words.
- Pass
- One left-to-right walk comparing every adjacent pair in the unsorted prefix. Avoid: iteration, round, sweep.
- Swap
- Exchanging two adjacent elements because the left is strictly greater. Three writes.
- Loop invariant
- A statement true before the loop and after every pass. Here: after pass k, the last k positions are final.
- Fixed suffix
- The last k positions after pass k. Never compared again. Avoid: sorted part, done area.
- Early exit
- Stopping after a pass with zero swaps, since zero swaps proves the array is sorted. Gives O(n) best case.
- Inversion
- A pair of elements out of order. Each swap removes exactly one.
- Stable
- Equal keys keep their original relative order after sorting. Bubble sort is stable because it uses strict greater-than.
- Quadratic, O(n²)
- Work grows with the square of input size: 10x input, 100x work.
Terms promoted here as lessons cover them; definitions may tighten as understanding deepens.