## Can we prove it will work?

## Sketch of an inductive argument (induction on the number of passes):

- Assume lower-order digits {j: j<i}are sorted
- Show that sorting next digit i leaves array correctly sorted
- If two digits at position i are different, ordering numbers by that digit is correct (lower-order digits irrelevant)
- If they are the same, numbers are already sorted on the lower-order digits. Since we use a stable sort, the numbers stay in the right order

Previous slide | Next slide | Back to first slide | View graphic version |