3 ms·
This is pretty cool. I've always found selection sort to be the most intuitive. When I was in school, a professor mentioned that bubble sort is sort of the "ea
by wtetzner 10y ago
This is pretty cool.
I've always found selection sort to be the most intuitive. When I was in school, a professor mentioned that bubble sort is sort of the "easy" sort that people would discover on their own, but I always thought it seemed complicated compared to selection sort.
Selection sort is basically "Find the next smallest item in the remaining unsorted list, and use it as the next value."
- igravious 10y agoI think you are both right :) Both seem to me like strategies that you'd intuitively hit upon. I think bubble-sort is a bit more mathsy but a certain type of mind would hit upon it. Because bubble-sort is "Go through the list swapping adjacent items depending on value, Keep doing that until you get no swaps." which is pretty trivial as well. I remember heap-sort kind of blowing my mind when shown to me. When this kind of topic comes up I am always reminded of D. J. Bernstein's Crit-bit Trees: https://cr.yp.to/critbit.html https://cr.yp.to/critbit.html