Counting sort under more sorting algorithms

I can’t get that why bhaiya has create a frequency array of size [largest + 1] . can anyone please make me clear.

@rahulparida933 hey you have to store frequency of all elements in freq array so its size should be largest element as starting from 0 maximum element which can come is largest and for safer side we add 1 to largest as it dont overfow ,in this way all elements frequency can be store in array.Hope you get it :slight_smile:

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.