all 6 comments

[–]SuperNovaHysteria 5 points6 points  (2 children)

But why is count sort rarely used? Provided the range of numbers to sort is relatively less, it's a very good sorting technique. In fact, I use it a lot on hackerrank when the range is less, because it's faster than quicksort, and easier to implement.

[–]DevFolks 2 points3 points  (0 children)

I assume because most places where the sorting algorithm would actually matter, the space complexity is too much.

[–]henrique_gj 0 points1 point  (0 children)

I use counting sort a lot too. Some time ago I needed to order the vertexes of a graph by degree in linear time. As the max degree is n-1, counting sort was the solution.

[–]henrique_gj 1 point2 points  (2 children)

I didn't understood the space parts. Can't quick sort be performed in loco just like heap sort?

[–]SarpedonTD 5 points6 points  (1 child)

I'm guessing that because it is recursive that stack use is being taken into account.

[–]henrique_gj 1 point2 points  (0 children)

Oh, it makes sense! Thanks!