Python Program for BogoSort or Permutation Sort
BogoSort also known as permutation sort, stupid sort, slow sort, shotgun sort or monkey sort is a particularly ineffective algorithm based on generate and test paradigm. The algorithm successively generates permutations of its input until it finds one that is sorted.(Wiki)
For example, if bogosort is used to sort a deck of cards, it would consist of checking if the deck were in order, and if it were not, one would throw the deck into the air, pick the cards up at random, and repeat the process until the deck is sorted.
while not Sorted(list) do shuffle (list) done
Sorted array : 0 1 2 3 4 5
Worst Case: O(∞) (since this algorithm has no upper bound)
Average Case: O(n*n!)
Best Case: O(n)(when the array given is already sorted)
Auxiliary Space: O(1)
Please refer complete article on BogoSort or Permutation Sort for more details!
Please Login to comment...