Spaghetti sort is a linear-time, analog algorithm for sorting a sequence of items, introduced by A. K. Dewdney in his Scientific American column. For a list of natural numbers, a rod of uncooked spaghetti is prepared with a length matching each number. The rods are held loosely in a fist and lowered so that they all stand upright on a table, and a flat hand lowered from above meets the longest rod first. That rod is removed and placed at the front of the output list, and the step is repeated until no rods remain, which yields the sorted sequence. Preparing the rods takes linear time, and lowering them takes constant time because the hand, the rods and the table act as a fully parallel computing device, so the source gives a worst-case time of O(n). The sort is stable and needs O(n) stack space, but it requires a parallel processor that is assumed able to find the maximum of a sequence in constant time, so it is a thought experiment about physical models of computation rather than a practical program.
Facts
Time Complexity
Time Complexity (category) Connections
Credited To
Source Spaghetti sort (Wikipedia)
In Field
Source Spaghetti sort (Wikipedia)
Invented
Source Spaghetti sort (Wikipedia)
Sources
1. Spaghetti sort (Wikipedia)
Body, time complexity paragraph
the worst-case time complexity of the algorithm is O(n)
In Group: Sorting and Searching Algorithms, Lead paragraph
is a linear-time, analog algorithm for sorting a sequence of items
In Field: Algorithms and Complexity Theory, Lead paragraph
is a linear-time, analog algorithm for sorting a sequence of items
Credited To: Alexander Dewdney, Lead paragraph [credited-to]
introduced by A. K. Dewdney in his Scientific American column
Invented: Alexander Dewdney, Lead paragraph
introduced by A. K. Dewdney in his Scientific American column
View the SourceReader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.