
How Inefficient Can a Sort Algorithm Be? (2012) [pdf] - signa11
https://sites.math.northwestern.edu/~mlerma/papers/inefficient_algorithms.pdf
======
gambiting
Sleep sort is still my favourite - if you're sorting numbers, just spawn a new
thread for each number, make it sleep that number of milliseconds and print
out the number after waking up. After the largest number of milliseconds
elapse, you have the sorted list of numbers nicely printed out.

~~~
saagarjha
Of course, then you're just relying on your scheduler, which may or may not
actually do the sort correctly.

~~~
tinus_hn
The scheduler doesn’t have a hard job if all but 1 thread is sleeping.

~~~
benchaney
Figuring out which threads to wake up when is an equivalent problem to
sorting. The kernel has to maintain a queue of threads sorted on their sleep
times in order to implement the sleep syscall in the first place

~~~
gambiting
Surely that's not true. You can keep a list of threads not sorted by their
sleep time and just iterate through them and see if they are due to be woken
up or not.

~~~
benchaney
That winds up being more work.

------
deugtniet
From the pdf "3 Worstsort: the final solution"

Reminds me of a German statistics professor that taught me the basics of
contemporary statistics. This guy would often say "final solution" with a
thick German accent, which was kinda funny to hear. But after a couple of
lectures I did discreetly tell him about the cultural annotations behind this
term. Afterwards he was a bit more modest in its usage.

~~~
majewsky
How can someone say "final solution" with a thick German accent? I'm German
myself and when I try to pronounce it with deliberately thick accent, it
doesn't change all that much.

~~~
rocqua
I'd guess something like 'ze final zolution'. With the second z a lot less
pronounced than the first. Mostly the pronunciation of 'the' by Germans is
easy to notice.

~~~
majewsky
The most obvious giveaways are pronouncing "the" like "s" and "w" like "v".
Also, consonants in general are pronounced too hard, making the pronunciation
less "flowing".

------
joosters
This still feels like ... cheating to me, if that's not too strong a word. If
your algorithm for sorting a list involves generating a bigger list and then
sorting that, then it's obvious that by recursion, you can make your sort
function take forever.

~~~
crave_
A program that does not halt is not an algorithm. If you want to create a
sorting algorithm, it has to halt, i.e. not run forever.

~~~
candiodari
Not seeing that in either the definition and essentially all control
algorithms, like say PID control, are meant to run "forever" (meaning longer
than you can foresee in the code, they need an infinite loop)

~~~
frabert
You could consider that in PID control the actual algorithm is the single
iteration, after which the output is sent out and a new set of inputs comes
in, thus restarting the algorithm. In an endless iteration, you never give out
any outputs

~~~
candiodari
You can't run PID in a single iteration. The integration and differentiation
parts would be 0 in any single iteration, and so it's quite PID control if you
look at it that way.

The description of the algorithm doesn't make much sense in a single iteration
either.

------
yogsototh
relevant:

[https://byorgey.wordpress.com/2019/02/16/worstsort/](https://byorgey.wordpress.com/2019/02/16/worstsort/)

------
xorfish
How inefficient can a sort algorithm be with O(1) or O(n) memory usage?

~~~
karmakaze
Random shuffle, verify if sorted.

~~~
cookingrobot
Make a random list, see if it’s sorted, then see if it’s the same as your
original set.

------
Rainymood
Why is bubblesort consistently spelled as bublesort?

~~~
faceplanted
Because the people spelling it wrong Just Haven't Met You yet

------
Taniwha
make a linear pass through the data, if they are in order quit, otherwise swap
two random entries and repeat

~~~
martin_a
So, the minimum running time for this would be O(1), but can one estimate the
maximum? I don't see how, but maybe I'm missing something.

~~~
astrobe_
This is known as BoZosort [1], which is said to be O(n!) on average.

[1]
[https://en.wikipedia.org/wiki/Bogosort](https://en.wikipedia.org/wiki/Bogosort)

~~~
kevinwang
I think it may be another factor of n slower than that

Edit: wow nevermind, I just read the paper linked to bozo sort in wikipedia.
They conjecture that it's O(n!) whereas bogosort is Omega(n*n!). Wow, that's
surprising!

------
smartstakestime
O(2 * n)

~~~
anonytrary
O(2*n) == O(n)

~~~
augustk
Or with common mathematical notation: O(2*n) = O(n)

