Model answer
For [170,45,75,90], the units pass gives [170,90,45,75], the tens pass gives [45,170,75,90], and the hundreds pass gives [45,75,90,170]. Each pass is a stable digit sort.
Use the key terms, then explain the reasoning.
Radix sort processes keys one digit at a time using a stable sub-sort such as counting sort.
Radix sort orders composite keys one position at a time. Least-significant-digit sorting starts at the lowest digit and depends on a stable sub-sort so earlier digit order survives later passes.
With d digits, n items, and base b, work is O(d(n+b)). A larger base reduces digit passes but enlarges count arrays and may worsen cache behaviour.
LSD passes
| Operation | Best | Average | Worst | Extra space |
|---|---|---|---|---|
| Sort | O(d(n+b)) | O(d(n+b)) | O(d(n+b)) | O(n+b) |
Stable counting sort by each decimal digit preserves the ordering established by earlier digits.
Open a prompt when you are ready to check your answer.