for j = 1 to n do
if A[i] swap A[i] and A[j
31–40 of 60 posts
for j = 1 to n do
if A[i] swap A[i] and A[j
Slightly off-topic, the article was fine except for one nitbit... I wonder what the author, "hilariously" making one sorting function print " sent to gulag" and calling it "stalin-sort", would think of "hitler-sort" which prints " burned in oven"? Please don't normalize mass-murderers, even for memes.
Slightly off-topic, the article was fine except for one nitbit... I wonder what the author, "hilariously" making one sorting function print " sent to gulag" and calling it "stalin-sort", would think of "hitler-sort" which prints " burned in oven"? Please don't normalize mass-murderers, even for memes.
My contribution: Power Sort. Start with p=0 and add 2^n for each n. Then subtract the largest power of 2 successively to get your integers ordered. Con: p will be very big. Pro: you don't need ifs!
Ooh, that's a fun one. Another con: you'd better hope your input contains no duplicates. :)
For an efficient implementation, one might want to round L+1 up to the nearest power of 2 to get crucial micro-optimisations based on instructions for bit scanning.
(I think this ends up being a very complicated phrasing of a counting sort.)
Slightly off-topic, the article was fine except for one nitbit... I wonder what the author, "hilariously" making one sorting function print " sent to gulag" and calling it "stalin-sort", would think of "hitler-sort" which prints " burned in oven"? Please don't normalize mass-murderers, even for memes.
It's an obvious joke, the point of which is that the Stalin Sort is destructive and doesn't actually get you what you want, and you'd never want to use it.
Isn't 'sleep sort' linear with respect to array size? O(n) sort achieved?
It is if you ignore how the underlying OS implements multitasking and sleep() in particular. And the kernel-side implementation usually involves some kind of priority queue of sleeping threads. So taken as a whole sleep-sort is just an convoluted implementation of heap-sort that outsources the actual sorting to OS.
My contribution: Power Sort. Start with p=0 and add 2^n for each n. Then subtract the largest power of 2 successively to get your integers ordered. Con: p will be very big. Pro: you don't need ifs!
> The probability of the original input list being in the exact order it's in is 1/(n!). There is such a small likelihood of this that it's clearly absurd to say that this happened by chance, so it must have been consciously put in that order by an intelligent Sorter. Therefore it's safe to assume that it's already optimally sorted in some way that transcends our naïve mortal understanding of "ascending order". Any attempt to change that order to conform to our own preconceptions would actually make it less sorted.
https://www.dangermouse.net/esoteric/intelligentdesignsort.h...
Earlier quoted context omitted.
For the operation of this algorithm, is there any meaningful difference between destroying the universe and destroying the observer(s)? https://en.wikipedia.org/wiki/Quantum_suicide_and_immortalit... EDIT: If you allow for the objects to spontaneously sort themselves, the runtime is O(1).
Surely O(n) for checking whether it is sorted?
Having an array and allocating "n"=="array length" qubits for it then implementing parallel version of randomsort (no while, while is serialization!) will be the fastest sorting algorithm.