Live data from Hacker News

Unconventional Sorting Algorithms

codingkaiser.blog

41–50 of 60 posts

Re: Unconventional Sorting Algorithms

#41
post #30
post #27

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?

You could just destroy all universes to ensure it's sorted in the remaining reality.

Re: Unconventional Sorting Algorithms

#42

Quantum bogosort is probably my personal favorite. Randomly permute the input using a quantum source of entropy. If the input is not sorted, destroy the universe. The only universe remaining is one where the input was already sorted. Runs in O(n) time.

Even without destroying the universe you can sort your list with a quantum source of entropy, just use:

    def cosmicraysort(list):
        while not sorted(list):
            pass

Re: Unconventional Sorting Algorithms

#44
post #30

Earlier quoted context omitted.

Surely O(n) for checking whether it is sorted?

You could just destroy all universes to ensure it's sorted in the remaining reality.

I'm confused. What reality is remaining if all universes are destroyed?

Re: Unconventional Sorting Algorithms

#45

Earlier quoted context omitted.

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.

I think OP gets the joke and is just saying it is in poor taste. Is it particularly different than their example of Hitler-sort burning stuff in an oven on failure? Or Columbine-sort, where the 15 coolest numbers get shot and then the rest of the numbers can get sorted.

But if the point is to mock the concept, how would it be considered normalizing anything?

Re: Unconventional Sorting Algorithms

#46

Earlier quoted context omitted.

You could just destroy all universes to ensure it's sorted in the remaining reality.

I'm confused. What reality is remaining if all universes are destroyed?

None, but in it the list is sorted.

Or rather a reality wherein it wasn't sorted doesn't exist anymore.

Re: Unconventional Sorting Algorithms

#47

Earlier quoted context omitted.

I'm confused. What reality is remaining if all universes are destroyed?

None, but in it the list is sorted. Or rather a reality wherein it wasn't sorted doesn't exist anymore.

True although not very helpful if you actually want to do something with the sorted list. But I suppose if you cease to exist, so does whatever problem sorting the list was intended to solve.

Re: Unconventional Sorting Algorithms

#48

Quantum bogosort is probably my personal favorite. Randomly permute the input using a quantum source of entropy. If the input is not sorted, destroy the universe. The only universe remaining is one where the input was already sorted. Runs in O(n) time.

Even without destroying the universe you can sort your list with a quantum source of entropy, just use: def cosmicraysort(list): while not sorted(list): pass

You can just kill the observer. Quantum immortality sort:

     def qisort(list):
        qshuffle(list)
        if not sorted(list):
            kill_observer()
Only in the universe in which th the list is sorted, the user will survive. There might be no such universe, but then the user is no longer waiting on the result.

Re: Unconventional Sorting Algorithms

#49

Earlier quoted context omitted.

I think OP gets the joke and is just saying it is in poor taste. Is it particularly different than their example of Hitler-sort burning stuff in an oven on failure? Or Columbine-sort, where the 15 coolest numbers get shot and then the rest of the numbers can get sorted.

But if the point is to mock the concept, how would it be considered normalizing anything?

I disagree that the point was to mock stalinism. It used Stalinism to joke about this type of sorting, but that doesn't mean it was mocking Stalinism.

Re: Unconventional Sorting Algorithms

#50

Quantum bogosort is probably my personal favorite. Randomly permute the input using a quantum source of entropy. If the input is not sorted, destroy the universe. The only universe remaining is one where the input was already sorted. Runs in O(n) time.

Unfortunately, randomly permuting the input takes O(nlog(n)) steps (you need at least this much time just to read in sufficiently many random bits). Perhaps a clever parallel architecture could reduce the runtime?
Post reply on HN