Bogo Sort

DESCRIPTION

Bogo Sort (also called Stupid Sort) is an iterative sorting algorithm particularly inefficient. It's based on randomly shufflying the elements of the data structure and then checking if they are correctly sorted. If not, repeat the process.

It is a probabilistic algorithm.
The amount of possible permutations of a data structure of `n` elements is `n!`, so it will take on average `n!` shuffles to reach the solution.
Each shuffle takes `n` operations, so the total average number of operations is `n × n!`

Since its performances depend entirely on probability, the worst case complexity is not measurable.

COMPLEXITY

Average Complexity | O(n × n!) |
---|---|

Best Case | O(n) |

Worst Case | ∞ |

Space Complexity | O(1) |