Recall & Review
beginner
What is the main idea behind Counting Sort?
Counting Sort counts how many times each number appears, then uses these counts to place numbers in the right order without comparing them.
Click to reveal answer
beginner
What kind of data is Counting Sort best suited for?
Counting Sort works best when sorting numbers that are small and within a known range, like 0 to 100.
Click to reveal answer
intermediate
Why does Counting Sort use an extra array for counts?
The extra array keeps track of how many times each number appears, helping to place each number directly in the sorted output.
Click to reveal answer
intermediate
What is the time complexity of Counting Sort and why?
Counting Sort runs in O(n + k) time, where n is the number of elements and k is the range of input values, because it counts and places elements without comparisons.
Click to reveal answer
advanced
How does Counting Sort maintain stability (keeping equal elements in original order)?
By placing elements in the output array from right to left using the counts, Counting Sort keeps the original order of equal elements.
Click to reveal answer
What does Counting Sort use to decide the position of each element?
✗ Incorrect
Counting Sort uses the count of each element to place it directly in the sorted output.
Which of these is a limitation of Counting Sort?
✗ Incorrect
Counting Sort requires the input numbers to be in a small range to be efficient.
What is the space complexity of Counting Sort?
✗ Incorrect
Counting Sort uses extra space for the count array and output array, totaling O(n + k).
How does Counting Sort handle duplicate elements?
✗ Incorrect
Counting Sort counts duplicates and places each occurrence in the correct position.
Which step is NOT part of Counting Sort?
✗ Incorrect
Counting Sort does not compare elements pairwise; it uses counts instead.
Explain how Counting Sort sorts an array step-by-step.
Think about counting first, then placing.
You got /4 concepts.
Describe when and why you would choose Counting Sort over other sorting algorithms.
Consider the data range and sorting speed.
You got /4 concepts.