Bogosort (was: old threaded languages, was Re: Symbolics)

From: CLASSICCMP_at_trailing-edge.com <(CLASSICCMP_at_trailing-edge.com)>
Date: Wed Mar 1 12:51:22 2000

> 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_at_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
Received on Wed Mar 01 2000 - 12:51:22 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:04 BST