5 ms·
O(n) Sorting Algorithm: Quantum Bogosort
- tantalor 13y agoWhat's the time-space complexity of destroying the universe?
- coherentpony 13y agoTime O(1). Space O(n).
- deleted 13y ago[deleted]
- ajkjk 13y agoIt doesn't really matter because in the surviving universe you don't do it.
- gizmo686 13y agoThere is only one universe, so it must be a constant, O(1)
- djent 13y agoI remember reading into this topic a while ago. Here is a relevant Wikipedia article. I, for one, look forward to the day when we all can have all our problems solved by destroying the universe. []http://en.wikipedia.org/wiki/Quantum_suicide_and_immortality http://en.wikipedia.org/wiki/Quantum_suicide_and_immortality
- McUsr 13y agoHahahaha.
- xxbondsxx 13y agoSome programmers on 4chan came up with a "Sleep sort" algorithm and then proceeded to optimize it, complete with example code: http://dis.4chan.org/read/prog/1295544154 http://dis.4chan.org/read/prog/1295544154 It essentially spawns a new thread for every item in the array, sleeps for an amount of time that scales with the item's value, and then prints out that item. So it's O(n + timeScale * $biggest_input) Pretty funny / entertaining if taken lightly :P
- groundshop 13y agoI wish I'd seen some of this before I took a discrete optimization course. I would have loved to submit some of this.
- gizmo686 13y agoThat seems like a ridiculous implementation of a quite reasonable algorithm. Instead of spreading them out through time, you can spread the values out through space. Assume you know that you elements are all positive integers less than 100 (or can be mapped to such). Allocate an array of length 100. In O(n) time, you can read through your unsorted list, and copy each element to the appropriate location in the array. Then you can read through the array and print out the values in order.
- simcop2387 13y agoThat sounds suspiciously like an insert sort. http://en.wikipedia.org/wiki/Insertion_sort http://en.wikipedia.org/wiki/Insertion_sort
- gizmo686 13y agoSimilar but asymptotically different. In insertion sort, if your partialy sorted list is [1,5], and the next element to insert is a two, you would scan the list until you arrive at the five, which. In the system I described the partialy sorted list would be represented as [1,_,_,_,5], and you would update the second element so it would be [1,2,_,_,5]. EDIT: After thinking about it, you could do the insertion step in O(1) time if you use a linked list instead of an array. The part where insertion sort gets its log(n) factor is in scanning the list, which can take (on average) no less than log(n) time. tantalor is correct in identifying this algorithm as pigeonhole sort.
- Whitespace 13y agoMore information about bogosort: https://en.wikipedia.org/wiki/Bogosort https://en.wikipedia.org/wiki/Bogosort
- cldr 13y agoI coded up a quick implementation of this in python, but in testing I found that after the algorithm was done I actually wanted a shuffled list.
- vlasta2 13y agoI may not understand quantum computing properly, but would not this approach require N entangled qubits? If no, can someone explain how it would function on less than N qubits, for example 1? If it does require N qubits...I can imagine a classical solution with O(n) and slightly less ridiculous hardware requirements.
- dchichkov 13y agoI think it requires N*log N un-entangled randomly initialized qubits. Please correct me if I'm wrong...
- deleted 13y ago[deleted]