Copyright © Philip M. Parker, INSEAD. Terms of Use.

BOGOSORT

Specialty Definition: BOGOSORT

DomainDefinition

Math

A terribly inefficient sort algorithm that repeatedly generates a random permutation of the items until the items are in order. (references)

Source: compiled by the editor from various references; see credits.

Top     

Specialty Definition: Bogosort

(From Wikipedia, the free Encyclopedia)

According to the Jargon File, the bogosort is "the archetypal perversely awful algorithm", 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 is named after the humourous term quantum bogodynamics.

This sorting algorithm is probabilistic in nature. If all elements to be sorted are distinct, the expected complexity is O(n!). The algorithm may finish in O(n) if you are extremely lucky, or if all elements are equal. The exact expected running time depends on how many different element values occur, and how often each of them occurs, but for non-trivial cases the expected running time is exponential or super-exponential in n.

It should be noted that with real-world pseudo-random number algorithms, which have a finite number of states, the algorithm may never terminate for certain inputs.

The following is an implementation in C++:

  1. include
  2. include

template void bogosort(std::vector& array) {
   while (! is_sorted(array))
       std::random_shuffle(array.begin(), array.end());
}

template bool is_sorted(const std::vector& array) {

   for (typename std::vector::size_type i = 1; i < array.size(); ++i)
       if (array[i] < array[i-1]) return false;
   return true;
}

Source: adapted by the editor from Wikipedia, the free encyclopedia under a copyleft GNU Free Documentation License (GFDL) from the article "Bogosort."

Top     

Anagrams: BOGOSORT

Scrabble® Enable2K-Verified Anagrams

Words within the letters "b-g-o-o-o-r-s-t"

-2 letters: robots.

-3 letters: boors, boost, boots, borts, broos, gobos, grots, robot, roost, roots, rotos, sorgo, toros, torso.

-4 letters: bogs, boor, boos, boot, bort, bots, broo, bros, gobo, gobs, goos, grot, oots, orbs, orts, robs, root, roto, rots, soot, sorb, sort, stob, togs, toro, tors.

-5 letters: bog, boo, bos, bot, bro, gob, goo, gor, gos, got.

 Words containing the letters "b-g-o-o-o-r-s-t"
 

+4 letters: astrobiology.

 

+5 letters: cryobiologist, motorboatings, postbourgeois.

Source: compiled by the editor from various references; see credits.

SCRABBLE® is a registered trademark. All intellectual property rights in and to the game are owned in the U.S.A and Canada by Hasbro Inc., and throughout the rest of the world by J.W. Spear & Sons Limited of Maidenhead, Berkshire, England, a subsidiary of Mattel Inc. Mattel and Spear are not affiliated with Hasbro.

Top     

Alternative Orthography: BOGOSORT


Hexadecimal (or equivalents, 770AD-1900s) (references)

42 4F 47 4F 53 4F 52 54

Leonardo da Vinci (1452-1519; backwards) (references)

American Sign Language (origins from 1620-1817 in Italy and, especially, France) (references)

=

Semaphore (1791, in France) (references)

Braille (1829, in France) (references)

Morse Code (1836) (references)

-...    ---    --.    ---    ...    ---    .-.    -

Dancing Men (Sir Arthur Conan Doyle, 1903) (references)

Binary Code (1918-1938, probably earlier) (references)

01000010 01001111 01000111 01001111 01010011 01001111 01010010 01010100

HTML Code (1990) (references)

&#66 &#79 &#71 &#79 &#83 &#79 &#82 &#84

ISO 10646 (1991-1993) (references)

0042 004F 0047 004F 0053 004F 0052 0054

British Sign Language (Fingerspelling, BSL; 1992, British Deaf Association Dictionary of British Sign Language) (references)

Encryption (beginner's substitution cypher): (references)

3649414953495254

Top     



INDEX

1. Anagrams
2. Orthography
3. Bibliography


  

Copyright © Philip M. Parker, INSEAD. Terms of Use.