2 ms·
That's an interesting point about randomness. You could implement a bogo-ish sort that's fully deterministic. Instead of randomly shuffling, iterate through all
by mikeash 11y ago
That's an interesting point about randomness. You could implement a bogo-ish sort that's fully deterministic. Instead of randomly shuffling, iterate through all possible permutations of the input. Assuming the input contains no duplicates, there are n! permutations and one which is sorted, so your average running time will be n n!/2, which matches bogosort.
Of course, in this age of cloud computing, we really should be using more modern terrible sorting techniques such as stacksort: https://gkoberger.github.io/stacksort/ https://gkoberger.github.io/stacksort/