r/algorithms • • Apr 26 '19

Sorting Algorithm Cheat Sheet

https://www.interviewcake.com/sorting-algorithm-cheat-sheet
86 Upvotes

6 comments sorted by

7

u/SuperNovaHysteria Apr 27 '19

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.

3

u/DevFolks Apr 27 '19

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

1

u/henrique_gj Apr 27 '19

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.

2

u/henrique_gj Apr 27 '19

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

5

u/SarpedonTD Apr 27 '19

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

2

u/henrique_gj Apr 27 '19

Oh, it makes sense! Thanks!