logoalt Hacker News

JKCalhountoday at 12:42 AM9 repliesview on HN

The appeal of bubble sort for me is that is it the only one I understand well enough to implement myself without having to think much about it.


Replies

somattoday at 9:56 AM

For me it's lsb radix, Yeah I know it only works on numbers, but much younger me independently invented it when slinging 3480 mainframe tape as a grave shift operator. The company had invested in mainframes early and by the time I had got there was was slightly disfunctional, they still had mainframe operators and we would run the nightly batch jobs to process orders. While they had a hard drive(the ramac) they never liked to update their programs to use it, so every major step of the process would read a tape and write a new tape(they used the tapes sort of like a massively inefficient version control, so the process could be restarted at any point) at the end of the night we would have to file a couple hundred tapes back in the library. As I hated randomly seeking through the library and was bad at ad hock sorting I put together a manual sorting routine so the numbered tapes could go back in order. What ended up working best for me I found out later was the good ol' LSB radix sort and I have a soft spot for it to this day.

bxparkstoday at 2:03 AM

I read this all the time from other people, but for me, Selection sort is the easiest to remember and implement. My next easiest would be Insertion sort.

Bubble sort doesn't click for me easily. I think it's because the terminating condition seems uglier than Selection sort or Insertion sort. I always have a little voice in the back of my mind, "Is this outer loop guaranteed to terminate?"

hmngtoday at 9:44 AM

As others have said, it is easy enough for a child in the 80s, with only a BASIC manual to come up with it. Been there, done that. Didn't even had a name for it. Later I read a magazine explaining several algorithms and found the name of what I had implemented.

For the curious, the ZX Spectrum microdrive listed files on the cartridges by order found on tape. I wanted to display it in alphabetical order like the "big" computers did.

show 1 reply
another_twisttoday at 9:53 AM

Merge and Quicksort are good ones too. Quicksort esp since the idea has a flavour of "I could come up with that". Its a beautiful algorithm.

ExtremisAndytoday at 12:54 AM

I felt this comment in my soul. I’ll never understand it: I’ve written thousands of lines of code (as a hobbyist) to solve all sorts of problems I’ve run into and yet always seem to struggle to wrap my mind around the core algorithms any real developer should be able to handle easily. This is why I’ve never pursued programming as a career.

show 1 reply
tzstoday at 1:54 AM

That surprises me. Selection sort seems like it should be easier to understand than bubble sort.

strkentoday at 1:15 AM

I understand merge sort enough to just jump in and write it. It does require a little more space and thought than bubble sort, though.

vlovich123today at 1:29 AM

Insertion sort and radix sort are also quite easy to understand, perhaps even more so.

anothernewdudetoday at 1:44 AM

Perhaps a sign of the trauma from university, but for me that's quicksort.