4 ms·
I guess it can be thought of as an unoptimized insertion or bubble sort. I think it is very possible to write this algorithm by mistake in intro compsci classe
by iib 4y ago
I guess it can be thought of as an unoptimized insertion or bubble sort.
I think it is very possible to write this algorithm by mistake in intro compsci classes when you try to code a bubble sort by heart. I would think TAs may have many such instances in their students' homework.
- mmcgaha 4y agoI am guilty. I wrote this sort for a gnu screen session menu years ago and even named my function bubsort.
- naniwaduni 4y agoThere's a surprisingly large class of "sorts people accidentally write while intending to write a bubble sort". This one is kind of special, though, since it's somehow more offensive to intuition than bubble sort itself.
- Dylan16807 4y agoBubble sort is offensive to intuition? I would have said it was the most intuitive, because each step is very simple and you only have to remember one numeric variable in your core loop.
- naniwaduni 4y agoBubble sort's inner loop is so hilariously pessimal that it's incredibly easy to accidentally write an insertion sort because you intuition tells you it can't possibly be intended to be that bad.