4 ms·
Another nitpick, several good quicksorts use insertion sorts for small sets which absolutely trounce the bubble sort. (I really think the bubble sort should nev
by Jach 16y ago
Another nitpick, several good quicksorts use insertion sorts for small sets which absolutely trounce the bubble sort. (I really think the bubble sort should never be mentioned; it's unintuitive and slow as tar. Teach the insertion sort!)
- burgerbrain 16y agoBubble sort is the fastest sort for sets of size two. Now, arguably there isn't really much functional difference between sorts on sets of size two, but the simplicity of bubble sort gives it an advantage for this extreme case.
- lukeschlather 16y agoThat generally applies to anywhere you're coding in something raw like C or assembly on very small datasets and don't want to deal with the mental overhead of picking and writing an efficient sorting algorithm. For sets of less than 100 items, it's not worth the bother. I actually did that in a programming contest once, having solved the hard part of the problem and being left with nothing but sorting the results.