The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

AOTM (Algorithm of the Moment) by jmaxsohmer 2006-09-25 19:03:48
bogo-sort: /boh`goh�sort�/, n.

(var.: stupid-sort) The archetypical perversely awful algorithm (as opposed to bubble sort, which is merely the generic bad algorithm). Bogo-sort is equivalent to repeatedly throwing a deck of cards in the air, picking them up at random, and then testing whether they are in order. It serves as a sort of canonical example of awfulness. Looking at a program and seeing a dumb algorithm, one might say “Oh, I see, this program uses bogo-sort.” Esp. appropriate for algorithms with factorial or super-exponential running time in the average case and probabilistically infinite worst-case running time. Compare bogus, brute force.

A spectacular variant of bogo-sort has been proposed which has the interesting property that, if the Many Worlds interpretation of quantum mechanics is true, it can sort an arbitrarily large array in linear time. (In the Many-Worlds model, the result of any quantum action is to split the universe-before into a sheaf of universes-after, one for each possible way the state vector can collapse; in any one of the universes-after the result appears random.) The steps are: 1. Permute the array randomly using a quantum process, 2. If the array is not sorted, destroy the universe (checking that the list is sorted requires O(n) time). Implementation of step 2 is left as an exercise for the reader.
From the Jargon File (http://www.catb.org/~esr/jargon/html/B/bogo-sort.html)
[ Reply ]
  so, who wants to start work on step 2? (n/t) by Astro-g2006-09-25 19:38:12
    That's why I like it :-) (n/t) by jmaxsohmer2006-09-25 22:00:49
  Interestingly, there's already an algorithm to by Arachnid2006-09-25 19:40:03
    Its not linear per se... by imperito2006-09-25 19:44:08
      O(n * k), actually by Arachnid2006-09-25 19:49:43
        you are imposing artificial constraints, though by imperito2006-09-25 19:52:22
          It's not n log n by Arachnid2006-09-25 19:55:48
            but it isn't constant. by imperito2006-09-25 19:57:47
              No, it's not! by Arachnid2006-09-25 20:00:27
                and what if you are sorting 10 000 000 000 of them by imperito2006-09-25 20:03:52
                  It doesn't matter. by Arachnid2006-09-25 20:09:35
    Wondering why everybody doesn't use it? by Didactylos2006-09-25 21:45:59
      Yup, I'm aware of those. by Arachnid2006-09-25 21:57:15

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)