Counting Sort
SortingMediumFrequencies counts to achieve O(N) non-comparison sorts.
Alt+Shift+C
Configuration Panel
Frequencies Accumulation Visualizer
50
21
82
23
34
55
16
47
Step: 1 / 1
Time Complexity
O(N + K) where K is the range of values (Max - Min)
Space Complexity
O(K) auxiliary counts list
Conceptual Overview
Counting Sort is a non-comparison integer sorting algorithm that works by counting the number of occurrences of each unique element value, then calculating indices directly.
Algorithm Idea
Initialize a frequency count array of size Max + 1 with 0. Scan the array to increment occurrences. Scan the count array to reconstruct sorted numbers.
Stable Sorting
Stable (when implemented with index prefix sums back sweeps)
In-place Memory
Out-of-place (requires O(MaxElement) frequency storage)
Source: CP-Algorithms search & sorting reference