Overview
Counting Sort builds a count table for a limited value range and uses those counts to place values in order.
Sorts integer values by counting how many times each value appears.
Compact metadata for implementation and discovery.
Counting Sort builds a count table for a limited value range and uses those counts to place values in order.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n + k)
Average
O(n + k)
Worst
O(n + k)
Space
O(k)
Show input values filling count buckets and then rebuilding the sorted list.
Counting Sort operates in O(n + k) time and O(k) space within the Distribution Sort family. Often compared with Radix Sort and Merge Sort.
What each reference supports for this entry.
Textbook support for Counting Sort invariants, recurrences, relaxation rules, or asymptotic analysis.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Radix sort commonly uses counting sort as the stable pass over each digit or key fragment.