Quantum Bogo Sort
QuantumBogoSort a quantum sorting algorithm which can sort any list in O(1), using the "many worlds" interpretation of quantum mechanics.
It works as follows:
-
Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the universe into O(n!) universes; however, the division has no cost, as it happens constantly anyway.
-
If the list is not sorted, destroy the universe. (This operation is left as an exercise to the reader.)
-
All remaining universes contain lists which are sorted.
As described above, is not a StableSort. A stable version might be produced as follows:
-
Configure the quantum randomiser to produce random code, rather than shuffle lists. Instruct it to generate some code.
-
If the resulting code is not a stable QuantumBogoSort, destroy the universe.
-
All remaining universes now have a stable QuantumBogoSort algorithm.