4 ms·
I question the inclusion of bubble sort especially two versions of it. I worry that people are more prone to using bubble sort, because it's conceptually simple
by mthomas 15y ago
I question the inclusion of bubble sort especially two versions of it. I worry that people are more prone to using bubble sort, because it's conceptually simple.
- fogus 15y agoYou'll never avoid the use of bubble sort by hiding it away from sight. People are constantly reinventing it regardless.
- kaiwetzel 15y agoI think it's nice to have it included to realize that while merge sort is not significantly more difficult (once the idea of divide and conquer is clear) the latter is a lot faster. I actually don't like the particular iterative version of merge sort, to me it's lacking in clarity; then again, I like to use the ternary operator ?: on the left side of an assignment in javascript (as an array index or function selector), so I'm probably not the right judge when it comes to clarity ;) I was thinking to include some sorting visualizations in my html5 canvas experiments, this looks like a neat start,thanks for posting it!
- chaosfox 15y agoI would before that, question the methods add/remove/get of specific positions on a linked list..
- xyzzyz 15y agoThis always strikes me as odd. Personally, had I heard about it, I would never come up with bubble sort myself, nor any of my friends I asked about it. The most intuitive sorting algorithm is obviously selection sort. I'd even say that merge sort is more conceptually clear than bubble sort. Bubble sort is not much easier to implement than selection sort either. It has no interesting properties which make it worth considering (unlike, for instance, insertion sort). The only possibility of one knowing bubble sort is by hearing about it on algorithms classes, and in that case one already know heapsort and quicksort, so that there is no need for bubble sort. To sum up, I fear bubble sort in production much, much less than, say, selection sort.
- kenjackson 15y agoTry asking 10 colleagues to right now write bubble sort on the white board. I bet at least half write some sorting algorithm that is not bubble sort. In contrast, if you ask these same 10 to do quicksort, you'll end up with 10 quicksort implementations.
- M1573RMU74710N 15y ago> The only possibility of one knowing bubble sort is by hearing about it on algorithms classes, That's simply not true. I know for a fact that for me personally the bubble sort was the most "intuitive" algorithm because when I was in elementary school we had a computer club, and we were given the task for figuring out how to sort a list. My implementation was a bubble-sort, and at the time I had absolutely no knowledge of sorting algorithms at all. Obviously different people will find different things "intuitive".