TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KURT KUZBA
from: TIM HUTZLER
date: 1998-03-20 18:14:00
subject: Re: Sort Algorithm

TH>  Anyone who chooses to use a bubble sort has got air
TH>  between their ears. [grin]
KK>If you are never REsorting your data, and only adding a single new
KK>element now and then, the bubble sort makes sense.
What makes 'sense' depends on what one knows about the alternatives.
The algorithm for a bubble sort is simple to understand and
implement. For very small arrays (less than, say, 30 elements) a
bubble sort is fine. However, for a large number of elements, even a
sorted list begins to fall down. That's because even a sorted list is
O(n), and an unsorted list is O(N^2/2)!
OTOH, a heap is only slightly more complex, but its effiency is
O(log2N), which means that it will be 10,000 times faster than a
bubble sort sorting only 100 elements! It is almost a million times
faster sorting 1,000 elements!
I wrote a heap sort class, and I use it a lot for priority trees and
stuff like that.
KK>A modification of it, which compares the item to be inserted to
KK>the middle element is even quicker, of course, but for a limited
KK>list, such as a top ten players list in a game environment, the
KK>bubble sort is perfectly adequate.
Yes, I would agree.
___ Blue Wave/QWK v2.12
--- Maximus/2 3.01
---------------
* Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.