🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Counting Sort

In plain terms

A linear-time sort that counts occurrences of each value.

Going deeper

Counting sort tallies how many times each value appears, then reconstructs the sorted order from those counts. It's fast when the value range is small.

Under the hood

O(n + k) for value range k; only practical when k isn't much larger than n. Stable and a building block for radix sort.

Examples

Sorting small-range integers, histogram building, radix sort subroutine.

Think of it like...

Like tallying votes per candidate, then listing them out in order of their tally positions.

Feedback & Bug Report