← Quiz: Counting Sort and Custom Sorting: all 13 questions
Quiz: Counting Sort and Custom Sorting · Question 13 of 13
Why can counting sort beat the O(n log n) limit for sorting?
Why can counting sort beat the O(n log n) limit for sorting?
- A.It uses a faster computer instruction
- B.It only sorts already sorted data
- C.It never compares two items; it counts values in a small known range, taking O(n + k)
- D.It skips half the items
Answer & explanation
Correct answer: It never compares two items; it counts values in a small known range, taking O(n + k)
The O(n log n) limit applies to sorts that work by comparing items. Counting sort uses the values as array indexes instead.
Can you get the rest right without peeking?
Take the timed Quiz: Counting Sort and Custom Sorting quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →