News for hackers. Stuff that matters.
Re:Cycle Sort by mfukar on Monday November 22, 2010 @05:32AM (#1929347)
I believe that the author is referring to the case when the array to be sorted contains only duplicates of a small number of items, where a perfect hash function can speed up insertion; this turns cycle sort's time complexity into Θ(n+k), with k being the number of hashes. In such a case, k is not negligible compared to n, so I wouldn't feel comfortable saying cycle sort is O(n), as he does.

In the general case, cycle sort is Θ(n^2) with a total space complexity of Θ(n).

edit:typos.

Re:Cycle Sort by kingkilr on Monday November 22, 2010 @09:35AM (#1929873)
This doesn't sound remotely right. If n is the number of elements, k is the number of distinct elements, and its O(n + k) as the author describes, k is trivially bounded by n (you can't have more distinct elements than you do elements). Resulting in O(n) complexity, how did you get O(n^2)?