Counting sort is most efficient when which condition holds?

  • A The range of input values is small
  • B The input is already sorted
  • C The input contains only negative numbers
  • D The input size is very large

Explanation

Counting sort runs in linear time when the range of input values (k) is small compared to n, because it counts occurrences rather than comparing elements.