[thelist] Sorting Algorithms

Marty Landman marty at face2interface.com
Fri Jul 27 11:56:37 CDT 2001


At 04:29 pm 7/27/01 +0100, you wrote:

>Bubblesort is great, but it always struck me as a bit
>inefficient. Are there any quicker ones?

It is. Bubble sort is easiest to implement but it averages N**2 comparison 
operations which gets horribly slow for larger lists. Once you get beyond 
the bubblesort, most every other technique is pretty similar in efficiency, 
at about

N * log_base_2 N

so if you're sorting about a million elements the bubble sort  makes about 
a trillion comparisons while the more efficient family of sorts will 
average about 20 million comparisons. Big difference at that large a 
volume, about 50,000 times faster if my arithmetic is working this afternoon.

Heapsort is in this efficient category of sorts and if you need help 
finding the algorithm let me know and I'll send it to you. It's pretty easy 
to implement too.

hth,

Marty

Face 2 Interface Web Solutions
Website Creation Made SIMPL(tm)
http://face2interface.com/Demo





More information about the thelist mailing list