# BogoSort

Unmodified
Added
Removed
• ## Description

r3 r4
11BogoSort is a highly ineffective algorithm notable only for its comedic value.
22
33The primary loop checks whether the input array is properly sorted and randomizes the entire array if it is not.
44
5 An analogy would be painting numbers on goldfish in a pond, counting the order in which the fish cross under a bridge, and dropping a **grenade** into the water whenever don't happen to like that order.
6
7 In other words, you'd have to be *crazy* to implement this algorithm.
8
9 To put that mathematically, the worst case scenario is that the algorithm takes an **infinite** amount of time to resolve.  Even looking at "average case" values, the expected number of swaps is :math:`(n-1)n!` and the expected number of value-comparisons is :math:`(e-1)n! + O(1)` .
5An analogy would be painting numbers on goldfish in a pond, counting the order in which the fish cross under a bridge, and dropping a **grenade** into the water whenever don't happen to like that order.In other words, you'd have to be *crazy* to implement this algorithm. Mathematically, the worst case scenario is that the algorithm takes an **infinite** amount of time to resolve.  Even looking at "average case" values, the expected number of swaps is :math:`(n-1)n!` and the expected number of value-comparisons is :math:`(e-1)n! + O(1)` .