0

Why count sort is not working?

I have created this code when i run it then it shows a error ..but its weird when i put code that is in count sort function into main function then erorr.. Here is the code: https://code.sololearn.com/cW6fW2btsXm6/?ref=app Please tell me why the code is not working...what the erorr really means and how to fix it

27th May 2021, 10:36 AM
Andrew
Andrew - avatar
8 Respostas
+ 2
Line 8: int count[k+1] = {0};
27th May 2021, 10:59 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
Martin Taylor Maybe Andrew is trying to implement something called `counting sort`. https://www.geeksforgeeks.org/counting-sort/amp/
27th May 2021, 11:10 AM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
Infinity thank you so much....
27th May 2021, 12:28 PM
Andrew
Andrew - avatar
+ 2
Martin Taylor Yes, that's a major drawback of using any such algorithm bounded by memory. The reason why its still used might be the time complexity which is O(n+k). It can be useful if the input is well known in advance to be in a range below the number that doesn't blow up the stack, as you mentioned. Space or Time, there is always a trade-off.
27th May 2021, 12:28 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
Andrew you're welcome
27th May 2021, 12:31 PM
Abhishek Tandon
Abhishek Tandon - avatar
0
Infinity Martin Taylor Guys please have a look at this one I didn't got any answer that helps me please clear my doubts.. https://www.sololearn.com/Discuss/2804536/?ref=app
7th Jun 2021, 3:41 AM
Andrew
Andrew - avatar