3 ms·
The problem is that you can look at this and, after a few seconds, think you've formed an intuition on how it must work, but your intuition is wrong. It seems l
by InsideOutSanta 2y ago
The problem is that you can look at this and, after a few seconds, think you've formed an intuition on how it must work, but your intuition is wrong. It seems like the only way to really show how weird this is would be by creating an animation that shows how it shuffles entries around.
(Edit) I gave it a shot: https://jsfiddle.net/odwh6cL5/45/ https://jsfiddle.net/odwh6cL5/45/
- varunneal 2y agovery beautiful simple animation. Good visualization of the proof of the algo; namely, that at each step i of the outer loop the first i elements are sorted (this is easy to show via induction)
- WantonQuantum 2y agoThank you for this!
- bunabhucan 2y agoAdd bubble sort in parallel and race them against each other!
- InsideOutSanta 2y agoHere you go: https://jsfiddle.net/790sfL21/30/ https://jsfiddle.net/790sfL21/30/ The difference between the two algorithms becomes even more apparent if you rerun the sort after the list is already sorted.
- bunabhucan 2y ago"Slower than bubblesort" is the acheivement here.
- layer8 2y agoHere are two other visualizations: https://www.youtube.com/watch?v=8raee-rvBw0 https://www.youtube.com/watch?v=8raee-rvBw0 https://www.youtube.com/watch?v=bydMm4cJDeU https://www.youtube.com/watch?v=bydMm4cJDeU
- Mithriil 2y agoThe visualization helped me realize something: The index doesn't change after the swap, so you always end up with the biggest number "in hand" after a full deeper level iteration loop.
- Mithriil 2y agoThis looks like a cool progress bar.
- InsideOutSanta 2y agoThat's a neat idea!