Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Bogosort
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Running time and termination== [[File:ExperimentalBogosort.png|thumb|Experimental runtime of bogosort]] If all elements to be sorted are distinct, the expected number of comparisons performed in the average case by randomized bogosort is [[Asymptotic analysis|asymptotically equivalent to]] {{math|(''e'' β 1)''n''!}}, and the expected number of swaps in the average case equals {{math|(''n'' β 1)''n''!}}.<ref name="Fun07">{{citation | last1 = Gruber | first1 = H. | last2 = Holzer | first2 = M. | last3 = Ruepp | first3 = O. | contribution = Sorting the slow way: an analysis of perversely awful randomized sorting algorithms | doi = 10.1007/978-3-540-72914-3_17 | pages = 183β197 | publisher = Springer-Verlag | series = Lecture Notes in Computer Science | title = 4th International Conference on Fun with Algorithms, Castiglioncello, Italy, 2007 | date = 2007 | url = http://www.hermann-gruber.com/pdf/fun07-final.pdf | volume = 4475| isbn = 978-3-540-72913-6 }}.</ref> The expected number of swaps grows faster than the expected number of comparisons, because if the elements are not in order, this will usually be discovered after only a few comparisons, no matter how many elements there are; but the work of shuffling the collection is proportional to its size. In the worst case, the number of comparisons and swaps are both unbounded, for the same reason that a tossed coin might turn up heads any number of times in a row. The best case occurs if the list as given is already sorted; in this case the expected number of comparisons is {{math|''n'' β 1}}, and no swaps at all are carried out.<ref name="Fun07"/> For any collection of fixed size, the expected running time of the algorithm is finite for much the same reason that the [[infinite monkey theorem]] holds: there is some probability of getting the right permutation, so given an unbounded number of tries it will [[almost surely]] eventually be chosen.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Bogosort
(section)
Add topic