Data Structures & AlgorithmsModerateTCS NQT · sorting

Problem: In counting sort, what limits its use on a large input?

  1. A. The input must be sorted already
  2. B. The key range must be small compared with n
  3. C. It requires floating-point keys
  4. D. It needs a heap

Correct answer: B. The key range must be small compared with n

Counting sort runs in O(n + k) time, so a large key range k makes it slow and memory-hungry.

More Coding Interview Problems questions

Exams that ask this topic