4 ms·
Worst case bubble sort is n^2 - this one is n^2 for all cases even an already sorted list.
by strangattractor 2y ago
Worst case bubble sort is n^2 - this one is n^2 for all cases even an already sorted list.
- NotAnOtter 2y ago...Right.. unoptimized bubble sort.
- ColinWright 2y agoOn any bubble sort, optimised or not, no swaps are made on an array that's already sorted. The routine in the article does. So no, it's not a bubble sort, unoptimised or otherwise. If you think it is a bubble sort then I'd be interested in seeing your implementation of a bubble sort, and an explanation as to why they are effectively the same.
- deleted 2y ago[deleted]