Skip to main content
GameDev.net gamedev.net
🔒 Locked

quantum bogo-sort

Started by coldacid Jan 7, 2004 at 6:27 PM 64 replies 3k views
Original Post
coldacid
coldacid
quote:
From the Jargon File The archetypical perversely awful algorithm (as opposed to bubble sort, which is merely the generic bad algorithm). Bogo-sort is equivalent to repeatedly throwing a deck of cards in the air, picking them up at random, and then testing whether they are in order. It serves as a sort of canonical example of awfulness. Looking at a program and seeing a dumb algorithm, one might say “Oh, I see, this program uses bogo-sort.” Esp. appropriate for algorithms with factorial or super-exponential running time in the average case and probabilistically infinite worst-case running time. ... A spectacular variant of bogo-sort has been proposed which has the interesting property that, if the Many Worlds interpretation of quantum mechanics is true, it can sort an arbitrarily large array in linear time. (In the Many-Worlds model, the result of any quantum action is to split the universe-before into a sheaf of universes-after, one for each possible way the state vector can collapse; in any one of the universes-after the result appears random.) The steps are: 1. Permute the array randomly using a quantum process, 2. If the array is not sorted, destroy the universe (checking that the list is sorted requires O(n) time). Implementation of step 2 is left as an exercise for the reader.
So... Any ideas on how to implement this? We know that we want to randomize the elements in a number of universes equal to the number of elements in the list (n), then check each universe to see if the list is sorted, and destroy those where the list isn''t. So how do we create these universes, check them, and destroy them? The rest is easy.
Tron3k
Tron3k
Uh, no. You''re supposed to destroy THIS universe.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
coldacid
coldacid
Read for the meaning, not for the words.
Tron3k
Tron3k
LOL ... you don''t understand Many-Worlds, do you?
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Fruny
Fruny
With new and delete, obviously.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
coldacid
coldacid
Could you provide an example implementation?
Fruny
Fruny
I''m afraid I can''t make it available to the public at large, lest anyone be tempted to use it, and this universe cease to exist.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Tron3k
Tron3k
Ok, I guess I'll have to clarify. The Many-Worlds interpretation of quantum mechanics is that whenever a random event occurs, the universe splits into many universes in which every single possibility occurred. So when you arrange the items to be sorted in a random pattern, the universe splits into many universes where every possible pattern occurs. Since the sorting machine destroys its own universe if the pattern is incorrect, only the universe in which the correct pattern occurred survives.

The most incomprehensible thing about the universe is that it is comprehensible. - Albert Einstein

[edited by - Tron3k on January 7, 2004 11:57:19 PM]
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
n0ob
n0ob
I for one, do not believe the many-worlds thoery. I believe that the universe is more of a 4 dimensional space/time in which there are rules we don''t quite understand yet.
Tron3k
Tron3k
Yeah, I don''t either. The part that really doesn''t make sense is - when does a "random event" occur? Supposedly it occurs when a quantum measurement occurs, and the wave function must collapse. This quantum measurement is not at all well defined.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
23yrold3yrold
23yrold3yrold
quote:
Original post by coldacid
2. If the array is not sorted, destroy the universe.

The error handling leaves something to be desired ...


Jesus saves ... the rest of you take damage.
"A page of history is worth a volume of logic." -- Oliver Wendell Holmes
Jesus saves ... the rest of you take 2d4 fire damage.
Tron3k
Tron3k
They also assumed that destroying the universe takes constant time.

Well, it probably does, but it might be a very LARGE constant time.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Extrarius
Extrarius
The order of time required to destroy the universe is irrelevant, because the universe in which the array is sorted does not destroy any universes and thus the actual sorting time isn't effected.
The quantum process to randomize the array is assumed to take 0 time though.
Also, I wouldn't be surprised if there is a quantum algorithm to test if something is sorted in less than O(n) time, so a quantum bogo sort may be possible that takes less than linear time.

[edited by - extrarius on January 7, 2004 12:11:51 AM]
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
PumpkinPieman
PumpkinPieman
In other words each and every decision that is made by everyone and everything in this universe multiplies the universe, then destorys the path(s) that are not taken? How can that be possible, it''s only a matter of a fact that someone right now is thinking or making a decision unintentionally. If there are 2 or more conflicting decisions at that very instant, would that mean that there are two different paths that our universe is taking or is it one path for both decisions?

Doesn''t seem very logical to me ...
Extrarius
Extrarius
No, the theory does not state that the ''wrong'' universes are destroyed, but that they keep on existing.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
cowsarenotevil
cowsarenotevil
quote:
Original post by Tron3k
Ok, I guess I'll have to clarify. The Many-Worlds interpretation of quantum mechanics is that whenever a random event occurs, the universe splits into many universes in which every single possibility occurred. So when you arrange the items to be sorted in a random pattern, the universe splits into many universes where every possible pattern occurs. Since the sorting machine destroys its own universe if the pattern is incorrect, only the universe in which the correct pattern occurred survives.



But... how do you write code to end it's own universe?

EDIT: "Implementation of step 2 is left as an exercise for the reader."

And also, when a random event (if they even exist) happens, we're in a whole slew of universes at once... but I only feel like I'm in one, because I am only in one. The other me's are just similar, and I wouldn't want to risk destroying myself in replacement for a person just like me but proud of his uber-1337 sorting program...



[edited by - coWsaRenOtevIl on January 7, 2004 12:19:11 AM]

[edited by - coWsaRenOtevIl on January 7, 2004 12:20:54 AM]
-~-The Cow of Darkness-~-
cowsarenotevil
cowsarenotevil
quote:
Original post by Extrarius
No, the theory does not state that the ''wrong'' universes are destroyed, but that they keep on existing.


"2. If the array is not sorted, destroy the universe (checking that the list is sorted requires O(n) time)"

pwned

-~-The Cow of Darkness-~-
Extrarius
Extrarius
PumpkinPieman appeared to be asking about the theory of many-worlds and not the theory of the quantum bogo-sort, and the many-worlds theory was the one to which I was referring in my reply to him/her
<1337>PWNED </1337>

[edited by - extrarius on January 7, 2004 12:22:03 AM]
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Fruny
Fruny
This specific algorithm requires the destruction of alternate universes (to make sure that nobody witnesses an unsorted array), but the multiple universe theory doesn''t state that alternate universes are destroyed when "a decision" is taken, which is the point Extrarius was correcting PumpkinPieman on.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
PumpkinPieman
PumpkinPieman
quote:
Original post by Extrarius
No, the theory does not state that the ''wrong'' universes are destroyed, but that they keep on existing.
So that could breed the theory that somewhere out there is a universe where all the wrong decisions were made, or an opposite to our universe.
Wouldn''t that be along the lines of thinking in aspect of time? If the time that once existed, acually did exist then it may be possible to go back to that time or universe?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.