3 ms·
In any case, you should retract you claim that Bubble Sort is slower on already sorted case. It is CS101, that bubble sort is one of the fastest in this case.
by SomeoneFromCA 3y ago
In any case, you should retract you claim that Bubble Sort is slower on already sorted case. It is CS101, that bubble sort is one of the fastest in this case.
- kragen 3y agoafter i posted the below comment to say 'oh yeah, you're right, thanks' someonefromca, perhaps inadvertently, edited the parent to say something completely different from what i was agreeing with. it previously said that there was a bug in the insertion sort code because it would swap things repeatedly, which is true and is a bug. my reply to their original comment is below oh yeah, you're right, thanks, it does do useless extra work if there are equal values in the list it should say if (tmp >= a[j-1]) break; however, this doesn't make it fail to terminate, which is a possible reading of your bug report