What is the range to be taken

What is the range to be taken…if it is the maximum element then the time complexity would be very large

hey @garganshul151 counting sort is a technique which uses the frequency of numbers present in array.Range is from min_element of array to the max_ELEMENT of array since below min and above max frequencies of elements are 0.
yaa if elements of array differs by very large gap counting sort will not be efficient.

Counting sort is efficient if the range of input data is not significantly greater than the number of elements int the array. Consider the situation where the input sequence is between range 1 to 10K and the data is 10, 5, 10K, 5K. then we have to iterate from 5 to 10K only to sort 4 elements.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.