Sorting medium time O(n + k) space O(n + k)
Counting Sort
For small non-negative integers, count how many of each value there are, turn the counts into end positions with a running sum, then place each input value where it belongs. Stable and comparison-free.
Counting sort: tally every value, then place them all in order.
1 / 17
Practice
Machine twin: /dsa-viz-v2/counting-sort.json — the full deterministic run as structured data.