You can replace the hand with any device that holds the spaghetti. This really is an O(n) algorithm.
Spaghetti sort seems to be an analogue variant of radix sort.
Re:Spaghetti Sort (2018)
by FartyMcFarter on Monday September 30, 2019 @03:00AM
(#21112411)
I suppose one could add a step 0 to the algorithm:
0: Manufacture a pair of hands big enough to hold all the spaghetti you'll need in the later steps.
Does this step take linear time as well?
Does it take O(n) time to manufacture computer memory? I don’t know, but it doesn’t affect the runtime of algorithms.
Re:Spaghetti Sort (2018)
by FartyMcFarter on Tuesday October 01, 2019 @05:27PM
(#21130888)
But many sorting algorithms work in-place, so they don't require extra memory beyond a small O(1) or O(log n) amount for bookkeeping.
When algorithms do require extra memory, they state this requirement as the space complexity.
Re:Spaghetti Sort (2018)
by random_savv on Monday September 30, 2019 @06:08AM
(#21113398)
I came here to write this comment. Glad somebody beat me to it! +1
Asymptotic times usually have assumptions on the problem size. On computers, you assume that memory access is constant time, which violates the laws of physics for arbitrarily large N.
It is an ideal hand on an ideal table.
Re:Spaghetti Sort (2018)
by Enginerrrd on Monday September 30, 2019 @11:07AM
(#21116132)
Yeah, and IMO it's not even a good theoretical way to look at an analog computer. The hard part that will eat up time is differentiating the small differences between spaghetti to arbitrary precision. Analog systems still have to deal with signal to noise ratio issues, which affects the decision criteria here as in, "which one of these is the next longest?".
Totally OT, but that reminds me of the first iPhone advertisements where they used exceptionally large hands to make the iPhone appear small. Quite funny if you think how smartphone sizes have developed since.
This 2007 blog article is hilarious from today's view: https://nwinton.wordpress.com/2007/06/24/the-iphones-bigger-...
If you ignore the usual meaning of linear time and restrict yourself to sorting lists of numbers that will fit in your hand, then spaghetti sort always runs in less time that however long it takes to sort the maximum amount of spaghetti you can hold in your hand. i.e. constant time.