Strangest Sorting Algorithms
codoholicconfessions.wordpress.com
codoholicconfessions.wordpress.com
And now we succeeded using AI and manual intervention for yet another problem that could be implemented with a simple classical algorithm.
The C++ implementation is very elegant:
while(!std::next_permutation(v.begin(),v.end()));
The complexity is O(N!)Any way the algorithm to get the next number in a collatz sequence is deterministic and has best and worst case complexity of O(1).
You’re then just choosing to run that algorithm against its own output a (potentially) infinite amount of times.
That said I take you point. I realize in another reply that what I had totally failed to recognize was my lecturer not clearly explaining that the definition he used was that an algorithm must be executable on a Turing machine.
The gp post is asking: what if you make a procedure that runs that on a given input number, repeatedly, until you end up with the output 1, and give the sequence of numbers you visited on the way. Is that an algorithm?
Every number we've tried so far does go to 1, but it's unproven if they all do. It's possible that there exist cycles not containing 1, or maybe some inputs go to infinity. We haven't been able to prove either way.
> [...] the definition he used was that an algorithm must be executable on a Turing machine
Yeah, that's a pretty good reason to choose a certain definition of an algorithm (that otherwise might be awkward) when you have a model you're fitting it into.
Aren't these the same steps for any given input?
1) Roll dice to get random number N
2) Get the Nth permutation of the input sequence (for some ordering of permutations)
3) Permute input sequence
4) If sorted: done, else goto step 1Think of it as “can I run this algorithm on a Turing machine”
I think a correct implementation would be sleep(x * k) where k is a constant factor determined by the platform
Want to pass an exam tomorrow? Set the machine to destroy the universe two days from now if you haven't passed the exam.
Create a poll asking to vote for the largest number, wait for results and put it at last. Repeat for remaining numbers. Oh wait that's selection sort. Nevermind.
>8 Intelligent Design Sort
These don't sort the list.
I hope I don't need to report you, comrade, for saying what is obviously a capitalist lie.
In this cases it is the list which sorts you. The end result is the same - the final observer perceives the list as sorted.