AW> I'm a student, learning C++ and as part of my homework I'm doing
AW> a small program that sorts a small array of data (only 8
AW> elements). With an array of this size, does it really matter what
AW> sort algorithm I use?
No.
AW> Wouldn't the dreaded Bubble sort give
AW> similar performance to other algorithms, (evne if repeated 100
AW> times)? So far I think I'll use the Selection Sort. But if there
AW> is one algorithm that shines when used on small arrays, please let
AW> me know.
The sort algorithm chosen doesn't matter unless the sorting is taking
significant time. It doesn't matter how many elements are involved if
as you suggested, it gets sorted again and again and again.
One feature of the list of objects that is significant is whether or
not the list is "mostly sorted" or not before the sort operation.
There are sort algorithms that will be blindlingly fast on "almost
sorted lists" and then bog down for random lists.
---
þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)
|