You are viewing a single comment's thread from:

RE: Different sorting algorithms for programming, and why it matters which one you choose

in #programming8 years ago (edited)

If the array / list is close to being sorted already, it looks like the bubble sort is the fastest sort method of the ones listed, probably because (if I recall correctly, I haven't looked at the code for a bubble sort in a long time).

Of course, that's a BIG assumption, although I'm sure there are ways you could rely on that case being true (none that I am aware of though)...

It doesn't seem to do as well if the data is fairly randomized, needs to be reversed or if the data has few items that are the same.

Great introduction, can't wait to see what else you come up with!

Sort:  

Bubble sort is actually very fast compared to most of the algorithms if the data is nearly sorted! Good observation. It is not very likely for the data to be almost sorted, although I'm sure there are cases where this is implemented!

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.032
BTC 64555.14
ETH 3086.03
USDT 1.00
SBD 3.85