JargonFile/original/html/B/bogo-sort.html
2014-03-27 18:54:56 +00:00

22 lines
3.2 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>bogo-sort</title><link rel="stylesheet" href="../../jargon.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.61.0"/><link rel="home" href="../index.html" title="The Jargon File"/><link rel="up" href="../B.html" title="B"/><link rel="previous" href="BOFH.html" title="BOFH"/><link rel="next" href="bogometer.html" title="bogometer"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">bogo-sort</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="BOFH.html">Prev</a> </td><th width="60%" align="center">B</th><td width="20%" align="right"> <a accesskey="n" href="bogometer.html">Next</a></td></tr></table><hr/></div><dt><a id="bogo-sort"/><dt xmlns="" id="bogo-sort"><b>bogo-sort</b>: <span xmlns="http://www.w3.org/1999/xhtml" class="pronunciation">/boh`goh·sort´/</span>, <span xmlns="http://www.w3.org/1999/xhtml" class="grammar">n.</span></dt></dt><dd><p> (var.: <span class="firstterm">stupid-sort</span>) The
archetypical perversely awful algorithm (as opposed to
<a href="bubble-sort.html"><i class="glossterm">bubble sort</i></a>, which is merely the generic <span class="emphasis"><em>bad</em></span>
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 &#8220;<span class="quote">Oh, I see, this
program uses bogo-sort.</span>&#8221; Esp. appropriate for algorithms with
factorial or super-exponential running time in the average case and
probabilistically infinite worst-case running time. Compare
<a href="bogus.html"><i class="glossterm">bogus</i></a>, <a href="brute-force.html"><i class="glossterm">brute force</i></a>.</p><p>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.</p></dd><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="BOFH.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="../B.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bogometer.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">BOFH </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> bogometer</td></tr></table></div></body></html>