Algorithm Vizualiser

Bogosort

In computer science, bogosort (also known as permutation sort, stupid sort, or slowsort) is a sorting algorithm based on the generate and test paradigm. The function successively generates permutations of its input until it finds one that is sorted. It is not considered useful for sorting, but may be used for educational purposes, to contrast it with more efficient algorithms.

Time Complexity:

Best Case: O(n)
Average: O((n+1)!)
Worst Case: O((n+1)!)

Bogosort works by simply randomizing the array you want sorted, then checking if it is sorted, continuing until it is. Due to the random nature of this sort it is one of the most inneffiecent sorts that exists. This leads to the average case of (n+1)! comparisons, this means that a list the size of 5 objects needs 720 comparisons and a list the size of 6 needs 5040.