News for hackers. Stuff that matters.
Re:Spaghetti Sort (2018) by mooshmoosh on Sunday September 29, 2019 @06:38PM (#21110054)
Linear time O(n) means that as you keep adding numbers to sort, the time taken is bounded by a linear function of how many numbers you have. Since there is an upper bound on the number of spaghetti strands you can hold in your hand, eventually you need to "Slam their lower sides on the table" in batches, and then merge sort the results. However because unlike in merge sort there is an upper bound on the size of the sub lists you use spaghetti sort will actually be O(n^2) instead of O(n log(n)).

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.

Re:Spaghetti Sort (2018) by madmax96 on Sunday September 29, 2019 @10:31PM (#21111287)
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?

Re:Spaghetti Sort (2018) by madmax96 on Tuesday October 01, 2019 @01:18PM (#21127942)
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
Re:Spaghetti Sort (2018) by chronial on Monday September 30, 2019 @05:39AM (#21113261)
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.
Re:Spaghetti Sort (2018) by c3534l on Monday September 30, 2019 @12:29AM (#21111778)
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?".
Re:Spaghetti Sort (2018) by jansan on Monday September 30, 2019 @05:00AM (#21113048)
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-...