Back to All Algorithms
Counting Sort
Category: Sorting | Time: O(n + k) | Space: O(k)
Visualization
Visual representation of the data structure
Enter an algorithm and input to start visualization.
About Counting Sort

An integer sorting algorithm that operates by counting the number of objects that have each distinct key value. It is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items.

Code Editor
The code is for reference. Editing it won't affect the visualization.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Frequently Asked Questions
About Counting Sort