i am not able to print the sorted array but my frequency array is correct pls help me…
here is my code
https://ide.codingblocks.com/s/60186
Counting sort (sorting algorithm)
You are printing the value if the frequency[i] is not equal to 0. Instead you have to print till the frequency of that particular element becomes 0 .
Refer this , there is slight change in your code - https://ide.codingblocks.com/s/60196
pls help me plsssssss
Hi Ankush, I am assuming you are not able to understand for what values is your code wrong.
Try it with multiple entries of a single element. Write 3 twice in your arr. and you will notice the fault in your output loop.
If you are still not able to figure out then here’s a hint. Just change the if to while in Line 25 of your code.
Hi Ankush, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.