4 ms·
A simpler sorting algorithm might be: until sorted(A) {assign a random order to the elements of A} There are n! ways to assign indices to the n items, so the
by troymc 5y ago
A simpler sorting algorithm might be:
until sorted(A) {assign a random order to the elements of A}
There are n! ways to assign indices to the n items, so the expected time for the algorithm to complete grows at least as fast as n!, i.e. not ideal.
- NoGravitas 5y agoThis is commonly referred to as "bogosort", the archetype of the perversely bad algorithm.
- iainmerrick 5y agoIs that really simpler? Both “until sorted” and “assign a random order” look significantly more complex than this entire algorithm.