Sorting algorithms/Bogosort: Difference between revisions

Content added Content deleted
No edit summary
Line 1: Line 1:
{{task|Sorting Algorithms}}{{Sorting Algorithm}}Bogosort a list of numbers. Bogosort simply shuffles a collection until it is sorted. (read the article on [[wp:Bogosort|Wikipedia]])
{{task|Sorting Algorithms}}{{Sorting Algorithm}}Bogosort a list of numbers. Bogosort simply shuffles a collection until it is sorted. (read the article on [[wp:Bogosort|Wikipedia]])

It is worth noting that "Bogosort" is a perversely inefficient algorithm and only used as an "in joke" among computer enthusiasts (geeks and nerds). Its typical run-time efficiency would be O(n!) ... the chances that any given shuffle of a set will end up in sorted order is about one in n factorial! Worst case is infinite! (We can never guarantee that a random shuffling will ever produce a sorted sequence).


Pseudocode:
Pseudocode: