Counting sort run-error


what’s wrong with my code ,it is working fine for inputs

Hello @agarwalbhavya06,

The run-time error is due to out of bound access.
The freq[] array is of size 10 i.e. it can store the frequencies of only 0 to 9
Solution:
the size should be k+1

Modified code:

Hope, this would help.
Give a like if you are satisfied.

1 Like