This is a really great introduction to algorithm analysis! I never thought bubble sort could be so educational.
Once you've understood this, and want a tad bit more, see The amortized cost of vector insert is 3
I appreciate you identifying ways to optimize Bubble sort, even though it remains inefficient compared to other sorts. You inspired me to code it out: wesleylhandy.github.io/bubble-sort/
This is so cool! Thanks so much for making it. Seeing the benchmarks for the three sort versions is super cool -- particularly in different browsers :)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.