https://ide.codingblocks.com/s/245948 this is a code for counting sort with inputs 0,1,2.
https://ide.codingblocks.com/s/245949 this is for 10^6 range and it is showing segmentation fault.
Counting sort range issues
it is mentioned that range of numbers could be upto 10^6 but you are making count arra of size 3 only.
corrected code
you did not see my code please see the second link
also why did you use count[1000005] and not just count[1000000] any special reason.
to access index 1000000 ur array size should be greater than 1000000 (because o zero based indexing).
it is common practice to take 5-10 more elements than max range, to accommodate both zero and one based indexing
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.