AI engineering glossary · Data structures algorithms
What is counting sort?
Counting sort: A non-comparison sorting method for integers in a small known range that counts how many times each value occurs and then writes the values out in order. It runs in O(n + k) time, where k is the range size.
Counting sort: an example
Sorting 1 lakh exam marks between 0 and 100 needs only 101 counters and one pass, far faster than comparison sorting.
Related terms
More Data structures algorithms terms
- Cycle detection
- Data structure
- Depth-first search
- Deque
- Dijkstra's algorithm
- Directed acyclic graph
- Divide and conquer
- Doubly linked list
Where you learn it
Counting sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.