5 questions to test your understanding
What is the time complexity of counting sort when sorting n integers drawn from the range [0, k−1]?
You need to sort 1,000 integers where each value can range from 0 to 1,000,000,000. Would counting sort be the best approach?
Counting sort avoids the O(n log n) comparison-sort lower bound by making fewer comparisons than merge sort — it simply compares elements more cleverly.
Counting sort is a stable sorting algorithm, meaning elements with equal keys appear in the output in the same relative order they had in the input.
Explain why counting sort can sort n elements faster than O(n log n) in some cases, but cannot universally replace comparison-based sorting algorithms.