12 ms·
Is this the simplest sorting algorithm ever? Quite possibly, but the paper is seven pages long!
by mannykannot 5y ago
Is this the simplest sorting algorithm ever?
Quite possibly, but the paper is seven pages long!
- troymc 5y agoA 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.