AlgoBazaAlgoBaza
Back to algorithms

Counting Sort

Instead of comparing numbers, it counts how many times each value appears and then writes them out in order. Lightning fast when the values come from a small range (e.g. grades 1-6).

Podstawowy
O(n + k)O(k)OIJOIBOBRALEMOZGIINSTALOGIK

๐Ÿงฎ Counting Sort โ€” Games

Play both games to master the algorithm!

๐Ÿ’ก

Tip: Start with Game 1 โ€” boxes and balls show where the count array comes from. In Game 2 you run every step of the algorithm yourself, exactly like tracing code on paper in a contest.