Hacker News new | ask | show | jobs
by leshow 2041 days ago
> I come from a culture that values memorisation over creativity and problem-solving. Fuck that. To this day, I still Google how to bubble sort.

I really hope this is hyperbole, but you should never use bubble sort. I can't think of a single legitimate reason you'd want to use it. Insertion sort, is a good O(n^2) sort to know.

2 comments

If you're working with rotating drum memory, bubble sort provides the best real world performance for any kind of data set that would fit on it.
Do I need to specify that I'm talking about modern computers? That's an interesting bit of trivia though.
I think it's a useful way to keep in mind that algorithmic complexity isn't everything in the real world, which also applies to today.

When would bubble sort be ideal? When it's relatively cheap to read data sequentially compared to backwards or randomly, and resetting to the initial read position isn't too costly.

Now I've nerd sniped myself, and am brainstorming how that situation might arise with modern systems...

Insertion sort is probably the one you'd come up with anyway, if you didn't know any sorting algorithms. If asked to sort a deck of cards, guess which algorithm almost anyone would naively use.

If there are instead two people to sort the deck of cards, they'll probably invent some variant on a merge sort!