What's the time-space complexity of destroying the universe?
O(n) Sorting Algorithm: Quantum Bogosort
11–19 of 19 posts
Re: O(n) Sorting Algorithm: Quantum Bogosort
#12Re: O(n) Sorting Algorithm: Quantum Bogosort
#13I 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.
Re: O(n) Sorting Algorithm: Quantum Bogosort
#14Some 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 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
Re: O(n) Sorting Algorithm: Quantum Bogosort
#15What's the time-space complexity of destroying the universe?
Re: O(n) Sorting Algorithm: Quantum Bogosort
#16Some 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 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
That 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.…
Re: O(n) Sorting Algorithm: Quantum Bogosort
#17Re: O(n) Sorting Algorithm: Quantum Bogosort
#18Some 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 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
That 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.…
Re: O(n) Sorting Algorithm: Quantum Bogosort
#19Earlier quoted context omitted.
That 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.…
That sounds suspiciously like an insert sort. http://en.wikipedia.org/wiki/Insertion_sort
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.