Talk:Spaghetti sort

message: How is this any different from Bead Sort except you call it spaghetti?  As commented already, the time complexity for this algorithm is O(n^2) if anything simply from the phase where you're trying to find the largest strand.  Furthermore, the space complexity of this algorithm is O(n^2) because each spaghetti strand is said to have a length (hence lowering them to a flat surface to level them, something you cannot do with "flat" integers) and also a position amongst the other strands.  In conclusion, this sorting algorithm is pure rubbish and should probably be removed.  -Anon  — Preceding unsigned comment added by 198.160.96.7 (talk) 19:31, 24 August 2011 (UTC)
replies: text: Why does it have to be described in terms of computers? It's not a computer algorithm. Not every algorithm is. Cairnarvon (talk) 13:10, 23 March 2008 (UTC)
replies: text:  Every algorithm is an algorithm for a theoretic computer. 131.180.159.92 (talk) 14:41, 19 March 2009 (UTC)
replies: text: But the interesting thing about this algorithm is that it is O(n) in time and space. If you tried to implement it on a theoretical computer (a Turing machine or similar) by simulating rods of spaghetti on a table it would no longer be O(n) time and space because 1 unit of simulated time would take perhaps O(n) units of real time. In other words, by implementing it on a theoretical computer, you remove the one interesting thing about the algorithm. 217.28.34.132 (talk) 11:22, 11 April 2009 (UTC)
thread_title: Algorithm explanation

message: Missing: finding the largest number to size your full-length spaghetti is also linear in the length of the list, assuming you have someplace to stash the best so far. If you have to mark and rewind (for big numbers when storage is scarce), you could in the worst case have to go through the list twice.  Julian Morrison (talk) 00:34, 26 March 2008 (UTC)
thread_title:  finding m 

message: Lowering arbitrarily-many rods to the table in O(1) requires an arbitrarily-large hand. Otherwise, it must be done piecemeal, at most some constant c at a time, which would be O(n) overall. Similarly, finding the largest rod takes an arbitrarily-large hand, or must be done piecemeal. So this step would be O(n) as well. But there are n finding steps, so this is an O(n^2) algorithm, not O(n).
Rmkeller (talk) 16:20, 26 April 2011 (UTC)
thread_title:  Lowering rods is not truly O(1) 

message: 2nd "external link" is dead.  — Preceding unsigned comment added by Kwaio (talk • contribs) 22:54, 10 December 2011 (UTC)
thread_title: Second external link

message: This has nothing to do with quantum computing. It seems to be just mentioned in a quantum computing presentation? I moved it back to other sorts.
Iamfscked (talk) 23:15, 5 January 2012 (UTC)
replies: text: Maybe Grover's algorithm and similar algorithms that amplify a set of values until the desired one crosses a threshold, analogous to aligning strands of spaghetti until the longest is obvious.--80.192.180.160 (talk) 16:15, 6 October 2013 (UTC)
thread_title: Quantum sort?

message: Space complexity is O(n.m) where n is number of spaghetti and m is number of different spaghetti lengths (m <= n). Required area (on the table or of the hand) is O(n) but the algorithm relies on dimension perpendicular to the table/hand for rod lengths which is O(m). Assuming m is O(n), space complexity is O(n^2). I have also some doubts that "obtaining rod of length X" is an O(1) operation but we can assume they are already prepared.
213.220.251.49 (talk) 19:27, 23 November 2012 (UTC)
thread_title:  Space complexity is not O(n) 

message: This algorithm is clearly absurd.  For example it claims that it works in O(n) space but if the maximum input number is very large, and the unit length of spaghetti is set too low, the imprecision in the spaghetti snapping step will lead to numbers which are very close being swapped in their spaghetti stick representation.  That is, the larger number might have a slightly shorter stick than a smaller number.  So clearly the unit length of spaghetti has to scale with the size of the input to be sorted, thus making the space O(n^2). 208.75.23.46 (talk) 20:13, 28 January 2015 (UTC)
thread_title: Untitled

message: If people like to see this as a computer algorithm, I think the following matches the current textual description.
Assuming an array of length n of positive integers.
  input: array of length n
    // Detemine longest spaghetti rod. O(n)
    max = findMax(array)
    // Prepare all rods.
    // spaghetti[i] represents number of rods of length i. O(n)
    spaghetti = new Array[max+1]
    for (i = 0 to n - 1)
      spaghetti[array[i]]++
    // Lower hand and move values to array (back to front).
    // If we discount empty steps (i.e. lowering the hand) this is O(n).
    counter = n - 1;
    for (i = max to 0) { 
      // Take into account duplicates.
      for (rod = 0 to spaghetti[i]) {
        // These lines run exactly n times:
        array[counter] = i
        counter--
      }
    }
Leastdoors (talk) 21:07, 19 August 2015 (UTC)
replies: text: The algorithm you are describing is Counting sort. I think this is a obviously made up algorithm. In my opinion, unless somebody demonstrates, how the algorithm can be implemented, it should be deleted. To people saying it doesn't have to be executable on a computer: Please don't forget, that this sorting method claims it has O(n) computational complexity. Quoting computational complexity theory: "Computational complexity theory is a branch of the theory of computation in theoretical computer science that focuses on classifying computational problems...". Additionally, you are generally not allowed to pick and choose, what actions are O(1). Any algorithm is O(1), if you take the algorithm itself to be a singular operation. This article tries to write off the need to demonstrate it's complexity by claiming that it need O(n) processors. In that case, please produce the pseudo-code for O(n) threads, that would somehow optimize the sort. --85.140.172.44 (talk) 18:33, 15 May 2018 (UTC)
thread_title:  Computer algorithm version 

message: It seems that the process of using physics to place the rods on a table is very similar to using Content-addressable memory.
The purpose of content addressable memory is to use hardware to perform a search. Should the article link to that page? 184.146.224.196 (talk) 12:43, 9 May 2021 (UTC)
thread_title:  Content addressable memory