Re:Show HN: Write a sort, watch it go
by T-hawk on Monday September 26, 2011 @08:27PM
(#3041302)
Looks like bubble sort is so slow because this implementation has a very high ratio between the costs of a compare and a swap. A swap involves redrawing large parts of the graphical area, while a compare is fast. Bubble sort makes N^2 swaps, as compared to insertion sort which makes N^2 comparisons but only N swaps.
When a swap costs the same as a compare, bubble sort is as fast as the other N^2 sorts.
Re:Show HN: Write a sort, watch it go
by thedufer on Monday September 26, 2011 @08:43PM
(#3041339)
Turn off "Quick Compare" to make comparisons take longer if you want a different ratio. By default, it takes about 1/15 as long to compare as swap (I thought the visualization looked better this way).
When a swap costs the same as a compare, bubble sort is as fast as the other N^2 sorts.