If anyone out there doesn't think sorting 1000
signed integers
in 6.8 millisecs isn't fast, code it up on your PC and
see how fast it is.
It depends a lot on the algorithm you use in the sort, of course :-).
I believe it's in _Numerical Recipes_ that possibly the worst sort
algorithm of all is disucssued: "Bogosort":
1. Take the list of numbers you want to sort.
2. Randomly reorganize them.
3. Check to see if they're sorted. If not, go back to step 2.
This is a Order(n*factorial(n)) algorithm. I've tried, but I've been
unable to come up with anything worse.
For your example of 1000 numbers, it'd take (assuming that each operation
takes a microsecond) about 10^2554 years to complete.
I think the only reason they discuss Bogosort is to emphasize that
just because Bubble Sort is the example used in lots of introductory
classes, that doesn't mean that you should ever actually use it for
anything :-). (Pre-RT-11 5.7 DIR/SORT notwithstanding, of course!)
--
Tim Shoppa Email: shoppa(a)trailing-edge.com
Trailing Edge Technology WWW:
http://www.trailing-edge.com/
7328 Bradley Blvd Voice: 301-767-5917
Bethesda, MD, USA 20817 Fax: 301-767-5927