This action might not be possible to undo. Are you sure you want to continue?

# Cyclesort - a curious little sorting algorithm : pro...

http://www.reddit.com/r/programming/comments...

MY SUBREDDITS

FRONT - ALL - RANDOM | PICS - FUNNY - POLITICS - GAMING - ASKREDDIT - WORLDNEWS - VIDEOS - IAMA - TODAYILEARNED MORE »

PROGRAMMING

comments

related

want to join? login or register in seconds | English

200

**Cyclesort - a curious little sorting algorithm
**

(corte.si) submitted 2 years ago by shenglong 83 comments share

search reddit

this post was submitted on 22 Nov 2010

all 83 comments

sorted by: best

[–] [deleted] 12 points 2 years ago

**200 points (70% like it)
**

341 up votes 141 down votes shortlink: http://redd.it/e9vpc

Don't confuse a secondary source with a primary source when critiquing the algorithm. See http://comjnl.oxfordjournals.org/content /33/4/365.full.pdf+html - of note, the original paper gives some applications of the algorithm.

permalink [–] zahlenwang 28 points 2 years ago*

username

remember me

password

reset password

login

Submit a new link

edit2: I apologize for comment-jacking my own comment and royally messing up the comment structure with programming repeated comments and edits, but here goes. The blog subscribe 430,810 readers article presents cycle sort as if it were an elaborate way to sort the integers [0 .. n]; it is more useful than that, 544 users here now and you can read the original 3 page paper by Haddon for accurate information. The Wikipedia article contains a /r/programming is a reddit for discussion and news about computer programming very similar algorithm (does not assume a key function, runs in quadratic time), and is clearly and concisely written, so you should read that too. You can disregard Girls Who Code everything else I've said in these comments, my comments below have no additional information.

hackNY

While the article makes cycle sort sound like a hilariously round-about way of sorting the integers [0 .. n], reading Guidelines the Wikipedia article clarifies the matter. The Please try to keep submissions on topic and of <s>actual</s> Wikipedia cycle sort algorithm does not use the magic indexing function, and runs in O(n ) time. Its advantage is that it is an in-place algorithm with O(1) additional needed memory that performs the minimum possible number of writes, i.e. one write for every element that does not start in the correct position. Also: The cyclesort_simple algorithm only works on permutations of sets of numbers ranging from 0 to n. There are other fast ways to sort data of this restricted kind, but all the methods I know of require additional memory proportional to n.

def sort_permutation(l): return range(0, len(l)) 2

high quality.

Just because it has a computer in it doesn't make it programming. Memes and image macros are not acceptable forms of content. If there is no code in your link, it probably doesn't belong here. App demos should include code and/or architecture discussion. Please follow proper reddiquette. Info Do you have a question? Check out /r/learnprogramming, /r/cscareerquestions, or stackoverflow. For posting job listings, please visit /r/forhire or /r/jobbit.

or def sort_permutation(l): for i in xrange(0, len(l)): l[i] = i depending on your definition of "additional memory".

1 of 12

03/27/2013 09:45 PM

and the situations in which cycle sort might be preferable over simpler algorithms. it has its uses.. or that there exist easier algorithms (and "all the methods I know. (3. Over on Hacker News.. morans. this same article has an interesting and wide-ranging discussion and the consensus is that cycle-sort is O(n). and assumes the existence of a key function -. 'd')])) Our point is not that cycle sort is a bad algorithm. as I said. Our point is that the author doesn't appear to know what he or she is talking about..com/r/programming/comments. then surely there are better explanations available -. 'a'). . the total contribution is "But you could just generate the sequence! Derp. Although someone who already understands permutations and cycles and sorting could easily fill in the gaps in the author's understanding. 'c'). why not join the discussion at /r/redditdev and steal our reddit code! Related reddits /r/technology /r/learnprogramming /r/coding /r/compsci /r/netsec /r/webdev /r/web_design /r/gamedev /r/cscareerquestions /r/reverseengineering /r/startups /r/techsupport Specific languages created by spez a community for 7 years message the moderators edit: At emef's suggestion I've now read the original paper cited by Wikipedia and the blog article. Over here on Reddit. Check out our faq..reddit. n] with possible duplicates. (2. 'b'). as others have pointed out. It could use some updating.. but that leaves the question of what name to give to the algorithm in the Wikipedia article on cycle sort..and 1 more » 2 of 12 03/27/2013 09:45 PM . The algorithm listed in Wikipedia originated from a stackoverflow post. n) with this.specifically it is for sorting data associated to the integers [0 . It would be reasonable to use "cycle sort" to refer to the original paper." You totally miss the point. For example. That and the "in-place" apply_cycle function makes the author look a little muddled. v = l[i] s[k] = v return s print (sort_permutation_with_data([(1. Nobody is actually going to sort the sequence of numbers range(0. def sort_permutation_with_data(l): s = [None] * len(l) for i in xrange(0. permalink [–] fonkprop 5 points 2 years ago* Jesus. we still can easily construct the sorted list..explanations that carefully explain the differences between sorting integers with or without associated data. permalink parent [–] zahlenwang -1 points 2 years ago* MODERATORS ketralnis spez Poromenos tryx dons masta kylev chromakode a_redditor If there is data associated to these integers. if one's goal were to give an introduction to cycle sort aimed at the novice... The author never mentions data being associated to the integers. the original algorithm is indeed O(n).a curious little sorting algorithm : pro.Cyclesort . It's useful if there is data associated with each key. http://www. (0." admits that s/he doesn't know of the easier algorithms). using cycle sort on data sets that lack a indexing function. len(l)): k. If you're an all-star hacker (or even just beginning).

. In this case. This is isn't about applicable situations. The integer and The data associated with the integer. Throughout the article he only sorts lists of integers (or other small sets). I wasn't clear. I certainly never thought of permutations that way until I attempted to solve the "swap" problem. this cyclic pattern can be a handy tool when analyzing permutations. Thus the examples the author presents can be trivially solved without cycle sort. I ended up discovering it myself when trying to prove that "number of swaps required to change one permutation to another is always odd or always even". He explains that it is clearly a special case. permalink parent [–] zohebv 6 points 2 years ago I am familiar with cycle sort.. That and the "in-place" apply_cycle function makes the author look a little muddled.com/r/programming/comments. and never associates values to these integers. This is exactly what the author of the article is talking about.reddit. Seriously. Our point is that the author doesn't appear to know what he or she is talking about.. This is what he is so keen on demonstrating and using it to do the O(1) space sort. as the author has explained. Sorry. He is perfectly lucid and understands everything that he is talking about..a curious little sorting algorithm : pro. The word "key" used by the author refers to the relationship between the integer and its index in the sorted array (which is the identity when there is only one of each integer). In fact.. In fact. Seriously. Although someone who already understands permutations and cycles and sorting could easily fill in the gaps in the author's understanding WTF! The fun thing about cycle sort is that it uses the not very obvious property that any permutation can be decomposed into a unique set of disjoint cycles. False The author never mentions data being associated to the integers His entire discussion about the key function is exactly about this association. You have two fields in the object. situations in which cycle sort might be preferable over simpler algorithms. You need to appreciate the pattern that all permutations are just a bunch of cyclic rotations. he is explaining things one logical step at a time. and "all the methods I know.. Clearly it requires O(n) additional space. The way you use the key function to associate data is this. edit: I did not intend to suggest that sort_permutation_with_data uses O(1) additional space..Cyclesort . That and the "in-place" apply_cycle function makes the author look a little muddled. the key function takes the object as parameter 3 of 12 03/27/2013 09:45 PM .. he is explaining things one logical step at a time. http://www.. what I'm referring to is that the author says the apply_cycle function is in-place when it explicitly is not. permalink parent [–] zahlenwang -1 points 2 years ago His entire discussion about the key function is exactly about this association. permalink parent [–] zohebv 2 points 2 years ago The word "key" used by the author refers to the relationship between the integer and its index in the sorted array (which is the identity when there is only one of each integer)." admits that s/he doesn't know of the easier algorithms I don't even .

Other than that. You think you can replace cyclesort with your obtuse algorithm above. and returns the integer field in the object. For example the key could be a one-way function. then since you do understand cycle sort.. Obviously it requires O(n) additional space. but really.Cyclesort .reddit. If you aren't the author please disregard. in the circumstance that you need to sort a collection of data associated to the integers [0 . Of course. you just don't understand what it does. not one damn thing you've said has been correct or useful. The "actual cycle sort" does use the equivalent of a "key" function because that's how the algorithm works you just don't understand it. The same can't be said for you everything you've said about this has just been flat-out wrong. The "actual cycle sort" does use the equivalent of a "key" function <s>By "actual cycle sort" I refer to the O(n ) algorithm discussed under "Algorithm" on the Wikipedia page.com/r/programming/comments. The key function is a more general way of specifying that data be associated with an integer. you should use cycle sort. but. permalink parent [–] fonkprop 3 points 2 years ago* The author seems to understand things just fine. This is the whole point: with cycle-sort we can do it in-place. do you? Your proposed replacement algorithm has double the memory requirement of cycle-sort. http://www. that's not really my business. unless I overlooked where the author discusses data associated with keys. You think you can replace cyclesort by "generating a range". Anyway. n] with O(1) additional memory and with the minimum number of writes. In most computer languages this is called an in-place update.. What he seems to be doing is destructively update the array that is passed in. (Yes.move along! permalink parent [–] zahlenwang -1 points 2 years ago* You and I both well understand the differences and relative merits of the various sorting algorithms. so it loses what makes the algorithm interesting. permalink parent [–] fonkprop 2 points 2 years ago You just don't really understand what you've read.) My claim is that the author of the article either doesn't understand or does a rather poor job of explaining things. I am not familiar with python. I did not mean to suggest that. And yet your contribution is the top comment.. Basically. it's the author's blog to do with as he or she pleases..) I haven't 2 4 of 12 03/27/2013 09:45 PM . I don't think I've said anything false. Ever wonder why proggit has degenerated to the cesspool of ignorance and despair that it is now? permalink parent [–] zahlenwang 1 point 2 years ago* everything you've said about this has just been flat-out wrong I can see how my comments give the impression that sort_permutation_with_data uses O(1) additional space.. edit: In the Shyamalian event that you are the author of the article. I'll let you guys get back to upvoting whichever commenter has the same ignorant misconception you have . you just don't understand its basic characteristics. I'd propose rewriting the article to reflect that fact.a curious little sorting algorithm : pro. (Wikipedia does elaborate under "Specific-situation optimizations" that the algorithm can be improved to O(n) if a hash function is available. really. what I'm referring to is that the author says the apply_cycle function is in-place when it explicitly is not. As simple as that. That algorithm only uses comparison of elements.

I am sorry about the confusion that has come from my using the name "cycle sort" for a slightly different algorithm. read the original paper by Haddon. it comes down to the fact that the blog never discusses associating data to keys. little knowing that it is. permalink parent [–] fonkprop -3 points 2 years ago Right. including the cases the article discusses.a curious little sorting algorithm : pro. my critique of the blog article stands unchanged. Instead. Other than the question of what name to give to what algorithm.. I have a better idea: why don't you just refrain from commenting on things you don't know the first fucking thing about? permalink parent [–] tias 1 point 2 years ago No matter who is right. So your entire idiotic critique is based on the fact that you a) didn't understand the article.. edit2: see edit to my root post regarding which algorithm is the actual cycle sort. permalink parent [+] fonkprop comment score below threshold (2 children) [–] cojoco -2 points 2 years ago morans 5 of 12 03/27/2013 09:45 PM . permalink parent [–] zahlenwang -1 points 2 years ago I wrongly assumed that the Wikipedia article is more trustworthy than a poorly written blog post. The purpose of my original remark was to clarify that cycle sort is. in fact. edit: your contribution A naive reader quickly looking at the blog article may get the impression that cycle sort can only be used for sorting the integers [0 .</s> You think you can replace cyclesort In nearly all cases.. n] (with possible repeats). As I've said. actually useful in certain circumstances. which is rather essential to the algorithm being of use. cycle sort can be replaced by a simpler or more general algorithm. permalink parent [–] zahlenwang 0 points 2 years ago Good call.Cyclesort . perhaps the algorithm discussed there is different from what I thought.com/r/programming/comments. there do exist cases where cycle sort is preferable. permalink parent [–] emef 3 points 2 years ago never trust wikipedia's algorithms. you thought you'd try to look clever by parroting the Wikipedia page.. Priceless. Fundamentally.. http://www. The wikipedia algorithm is not that in the original paper.. Now that I've read the original paper. I know you're the one being an ass about it. in fact.reddit. and b) you didn't refer to the original paper linked to right in the opening fucking paragraph. I see that the blog is more faithful to the original paper than the Wikipedia article is (although that raises the question of what name to call the algorithm that appears on Wikipedia). wrong..

. permalink parent [–] zohebv 3 points 2 years ago 2) 6 of 12 03/27/2013 09:45 PM . http://www. This is getting really infuriating! The blog post is perfectly well written. permalink parent [–] hobbified 1 point 2 years ago* Your inability to follow the blog post or map the key function to the perfect-hash fn is not the fault of the author. runs in quadratic time) So it looks like you did not follow the wikipedia article either. I think you're missing the point entirely. Notice this sentence . sorry. By the way.. Yes. corrections and edits. permalink [–] zohebv 2 points 2 years ago parent The blog article presents cycle sort as if it were an elaborate way to sort the integers [0 .a curious little sorting algorithm : pro. that's what I thought. permalink parent [–] cojoco 2 points 2 years ago Oops. permalink parent [–] cojoco 1 point 2 years ago But a hundred times worse than O(n) is still O(n). even after 100s of comments.... The Wikipedia article contains a very similar algorithm (does not assume a key function. it is more useful than that. that was part of the joke. we're all talking about a sorting algorithm in which the final index of every data element is incorporated into every key I think anyone would have a hard time writing a sort for this kind of data which was worse than O(n) permalink parent [–] Nebu 1 point 2 years ago I think anyone would have a hard time writing a sort for this kind of data which was worse than O(n) I bet I could write a sort that's a hundred times worse than O(n). That's not at issue.reddit."a constant-time perfect hash function can greatly speed up finding where to put an item1. then uses it do demonstrate an in-place sort which is the most obvious application..com/r/programming/comments. n]. You did not follow it or the usage of the key function. What is is the fact that the blog post never mentions the general O(n algorithm. permalink parent [–] Nebu 1 point 2 years ago Yeah. Stop shitting on the author of the blog post who is obviously several notches smarter than you and has put up a well written article and understands the topic way better than you do. the key function! Your inability to follow the blog post or map the key function to the perfect-hash fn is not the fault of the author. only the O(n + m) one that arises from it.Cyclesort . The author first explains a very interesting fact about permutations. If you want to make a comment about something just do it. A certain amount of intelligence needs to be used when reading and insisting that the author should use the exact phraseology from wikipedia is ridiculous. turning the sort from Θ(n2) time to Θ(n + k) time" What is this constant-time perfect hash function?! Precisely.. I was feeling a bit defensive after all of the downvotes.

It is overall an okay presentation of a cycle sort. I disagree (though I originally was conflating the Wikipedia algorithm with the Haddon algorithm). turning the sort from Θ(n2) time to Θ(n + k) time" I am responsible for some confusion here. c): # Extract the cycle's values vals = [lst[i] for i in c] # Rotate them circularly by one position vals = [vals[-1]] + vals[:-1] # Re-insert them into the list for i. permalink parent [–] zahlenwang 1 point 2 years ago* Notice this sentence . but need an O(n) key function. meaning "use the cycle generated for that list to order the list" permalink [–] euneirophrenia 10 points 2 years ago Here's a Python function that applies a cycle to a list in-place: def apply_cycle(lst. it does not appear in the Haddon paper. that was my response too. Why should the article by the author be an exact replica of the wikipedia article? If we cannot write a decent O(1) key function. and requires a key function. he didn't mention that . Instead. permalink parent [–] zahlenwang 0 points 2 years ago 2). obviously the algorithm will be O(n The algorithm is only interesting when we have a fast key function and this is what the author described. we can't sort faster than nlogn. http://www. offset in enumerate(c): lst[offset] = vals[i] This is the exact opposite of in-place permalink 7 of 12 03/27/2013 09:45 PM . I have come across as far harsher against the original blog post than I had originally intended.. However all the back-and-forth has made things rather ugly. I mean the O(n ) one in the Algorithm section -. Hey why doesn't this fool just print out 1. I personally don't think so)."He he.com/r/programming/comments.reddit.that runs in quadratic time and requires no key function. The O(n) specialization given in the following section is identical to cycle sort as originally presented by Haddon.n directly.. Sure. permalink parent [–] Doctor -3 points 2 years ago 2 Yeah.Cyclesort . so its omission is not a big deal (or at least."a constant-time perfect hash function can greatly speed up finding where to put an item1. duh. It's quick to sort integers when each integer is its own sorted index? Well.a curious little sorting algorithm : pro. /: 3 4 5 1 produces: 3 0 1 2 and /:~ 3 4 5 1 gives 1 3 4 5 ~ makes the /: (grade is the name of that) reflexive. the comments here are childish . This is just ridiculous. permalink parent [–] basscadet 3 points 2 years ago User's of J will find this familiar. While it would have been nice for the blog post to discuss the quadratic algorithm. This was because the focus of the post was on demonstrating O(1) space complexity and the reduction of a permute action to a rotation of disjoint sets of objects....if the key function isn't O(1) as expected the complexity of the algo is not O(n). I stated elsewhere (very deeply buried of course) that when I refer to the Wikipedia algorithm. the author doesn't know what he is talking about".

and can be completely opaque to anyone who isn't already familiar with the technique. lst[offset] = vals[i] permalink parent [–] serendib 1 point 2 years ago Would have been fun if he did a true in-place swap: http://en. because of this exact point! Could it also sort permutations of subsets of [0. In this case you need a sort that can quickly get things moved around . which is a much simpler task than to sort it. so they must be executed in strictly sequential order. 8 of 12 03/27/2013 09:45 PM . just generating the range is not enough.. so it lives only on tape (or disk. On modern CPU architectures. lets assume that sorted read doesn't need to happen often.. but I'd be surprised to ever see it in practice. and often faster.org/wiki/XOR_swap_algorithm permalink parent [–] euneirophrenia 1 point 2 years ago XOR swap is a neat trick to show an intro CS class.. permalink parent [–] geon -1 points 2 years ago Yes.wikipedia. In the XOR technique.Cyclesort . permalink parent [–] bluGill 3 points 2 years ago What if the data is far too big to fit in memory.. since you also need to go through the original array again to find the satellite data. and should be converted to an array. so you need to minimize that.[2] The XOR swap is also much less readable. In that case. so insertion sort isn't worth the bother (perhaps 90% of access is for one of the 10 previous records).. The wiki article you linked sums up the reasons nicely Most modern compilers can optimize away the temporary variable in the naive swap.n]? Nope! But then I looked at this little snippet of code: def key(element): return element And then it struck me: this is not useful for sorting the numbers themselves.a curious little sorting algorithm : pro. you can simply generate that range.com/r/programming/comments. it's O(1).reddit. but tape is worse).. it is advised to test the speeds of both the XOR technique and temporary variable swapping on the target architecture permalink parent [–] geon 19 points 2 years ago If you know the data is a continuos range [0. However once in a while (before year end inventory?) you need to read everything in sorted order. but when there is also satellite data/values associated to them. Further. But in that case. If I do that lazily.n]. [–] julesjacobs 3 points 2 years ago http://www. this is a really stupid data structure to begin with. If efficiency is of tremendous concern. One reason is that modern CPUs strive to execute commands in parallel via instruction pipelines. the XOR technique is considerably slower than using a temporary variable to do swapping.. the inputs to each operation depend on the results of the previous operation.but your access time to the data is the critical factor in speed. Presumably he means destructively as opposed to non-destructively. permalink [–] yatima2975 16 points 2 years ago I was wondering whether I was missing something. in which case the naive swap uses the same amount of memory and the same number of registers as the XOR swap and is at least as fast..

n]. Pseudocode: foreach(someList as element) someArray[element. where hashtables and arrays are almost-but-not-really the same thing. Sure it is a far fetched situation. permalink parent 9 of 12 03/27/2013 09:45 PM . permalink parent [–] DoorsofPerceptron 1 point 2 years ago You can have 'holes' in the cycles.Cyclesort . the key would be a completely pointless detail. In this case too. http://www. that have some field which you sort by. permalink parent [–] MarshallBanana 27 points 2 years ago Nobody sorts lists of just integers.com/r/programming/comments. If I wouldn't do it this way. However it can happen.. As the article explains.key] = element. it makes sense to instead use an array. permalink parent [–] MarshallBanana 7 points 2 years ago You don't. if the range of the integers is small enough. The author goes on to claim: The Haddon paper presents a solution for one common case: permutations whose elements come from a relatively small set. pick the minima and maxima and then cycle sort within a larger array of size min . If the keys are all the integers of a range [0. you can simply generate the output directly. or point to numbers that don't have a value in them. if you know you have integers you can make a single pass. permalink parent [–] piderman 2 points 2 years ago The thing is though. permalink parent [–] geon 1 point 2 years ago Good point..reddit.a curious little sorting algorithm : pro. (Unless you do it in PHP. permalink parent [–] jennyther 5 points 2 years ago and the first step in converting it to an array would be what exactly? Not sorting it into order surely? permalink parent [–] geon -1 points 2 years ago The datastructure described would be an association list. This means the algorithm is weakly linear. the array would be sorted.value After this conversion.. So if you get some random data set from a database with indexes to sort on. where the number of occurances of each element is known. That field can be an integer that fulfills the requirements to use cyclesort.. you first have to sort the integers before you can use cyclesort.max. where the key of the association list is used as the index. You usually sort a list of data records. This means that. Cycles are fun but this algorithm is worse than useless.) permalink parent [–] durandal42 4 points 2 years ago Indeed. for cyclesort to work you have to know in advance the occurrence and the order of the integers you use since you use the keys themselves to lookup their place in the sequence.

nobody is actually going to sort a continuous range [0. when you start evaluating it. it's because integers by themselves are already sorted. It wouldn't hurt the time complexity.. permalink parent [–] Felicia_Svilling 2 points 2 years ago Even for the part there you count the occurances of every key? permalink parent [–] MarshallBanana 3 points 2 years ago If the range of keys is less than the size of the sorted array. permalink parent [–] cojoco 1 point 2 years ago True. Although at that point you are basically just reinventing bucket sort.. You could just go through the list and count how many there is of each key. If you want to sort the integers from one to five. 3.com/r/programming/comments. and more downvotes when you trivialize me pointing out that what you said was trivial! permalink parent [–] stlunatic102 1 point 2 years ago yes but can we HEAR it? permalink [–] satayboy 1 point 2 years ago I'll bet this will revolutionize space exploration.n]. permalink parent [–] cojoco 0 points 2 years ago If you do anything lazily.. it's O(1). permalink parent [–] geon 1 point 2 years ago True. This type of algorithm is used when there's data associated with each key. Yowsers! What's the point? Downvotes for pointing out that your statement was trivial. but any other algorithm won't stay O(n). permalink parent [–] fonkprop 2 points 2 years ago Rest easy. 2. when you start evaluating it. permalink [+] phrstbrn comment score below threshold (14 children) 10 of 12 03/27/2013 09:45 PM ..reddit. the result is 1. 5 regardless of what order they came in. my poor baffled friend . permalink [–] [deleted] 2 years ago parent [deleted] permalink parent [–] dnew 1 point 2 years ago Assuming this is an actual question.a curious little sorting algorithm : pro.Cyclesort . but any other algorithm won't stay O(n). permalink parent [–] MarshallBanana 6 points 2 years ago Memory requirements are smaller than bucket sort.. yes. [–] Felicia_Svilling 0 points 2 years ago http://www. 4.

permalink [–] spyne-02139 -1 points 2 years ago The author would be more clear. Sorting by tallying. [–] skulgnome -1 points 2 years ago http://www. can be achieved in linear time. as there isn't any particular notation to fall back on (as there would be with. examples are really the only way to get across the idea. for example. permalink parent [+] Mikle comment score below threshold (0 children) [–] theresistor 4 points 2 years ago It's impossible for a comparisons-only sort to be done in less than O(n log n)..pdf+html does a good job of explaining cycles for the purpose of this algorithm permalink parent [–] pkrecker 1 point 2 years ago OK fine I deserve the downvotes for being too harsh.reddit. sometimes you can do better. permalink parent [–] pkrecker 1 point 2 years ago I think the original article at http://comjnl. permalink parent [–] rabidgnat 7 points 2 years ago It's impossible to do a comparison-based sort better than O(n log(n)). Upvoted for being the best troll algorithm all year. useless and not any more interesting than the other linear time sorting algorithms out there. When your items almost covers all possible items. If it's not a troll algorithm. permalink [–] noumuon 3 points 2 years ago he does do a moderate job of describing a cycle. This algorithm is only linear for data sets that have additional constraints that would require more comparisons to verify.. permalink parent [–] ethraax 5 points 2 years ago 11 of 12 03/27/2013 09:45 PM . group action of an additive group of integers mod n on some other set). If you don't use comparisons.com/r/programming/comments.oxfordjournals. permalink [–] pkrecker -2 points 2 years ago I'm pretty sure that this is blog post is a fail.full. upvoted for being the best non-troll algorithm all year. Bead sort has a theoretical complexity of O(1). It begins when he doesn't really describe the concept of a cycle (2 examples but no concrete notation?) and continues until the end when you realize that this guy has just written a massive blog post on something that is old.Cyclesort . permalink parent [–] [deleted] 2 years ago* [deleted] permalink [–] time_circuits 10 points 2 years ago Impossible for comparison sorts. if in the third paragraph he/she notes that a cycle is a separate entity applied to a list and not merely a property of the list.. But I still think the original paper does a better job of explaining this than the blog post. yes. etc.a curious little sorting algorithm : pro. and real-world complexity of O(sqrt(n)). and thus pull it up to O(n log n).org/content/33/4/365. bucket sort is O(n)..

..Cyclesort . permalink parent about blog about team source code advertise help wiki FAQ reddiquette rules contact us tools mobile firefox extension chrome extension buttons widget <3 reddit gold store redditgifts reddit. REDDIT and the ALIEN Logo are registered trademarks of reddit inc.a curious little sorting algorithm : pro.reddit. http://www. All rights reserved..tv radio reddit Use of this site constitutes acceptance of our User Agreement and Privacy Policy.. They don't exclusively use comparisons. so that limit (which is true of comparison-based sorts) does not apply. © 2013 reddit inc. Radix sort and bucket sort are both sorting algorithms with linear time complexity.com/r/programming/comments. π 12 of 12 03/27/2013 09:45 PM .