Which sorting algorithm would you choose for sorting a small array of integers with a known, small range of values?
Counting Sort would be ideal, as it runs in O(n + k) time, making it very efficient when the range is small.
Thatâ€™s correct. Counting Sort is highly efficient when the range of input values (k) is small.
Can you explain how the counting array works in Counting Sort and how it helps achieve linear time complexity?