Talk:Sorting algorithm: Difference between revisions

Content deleted Content added
Table visibility: new section
add talk header, banner holder, archive bot. sign and sort old topic
Line 1:
{{Talk header}}
{{Banner holder |collapsed=yes|1=
{{ArticleHistory
|action1=FAC
Line 10 ⟶ 12:
{{WikiProject Computer science|importance=Top}}
}}
}}
{{Archive box|
{{User:MiszaBot/config
*[[/Archive 1]]}}
|archiveheader = {{Talk archive}}
 
|algo = old(365d)
== How bad is this code ==
|maxarchivesize = 100K
template <class iterator> void gnome(iterator first, iterator last){ // O(n^2)
|minthreadsleft = 5
iterator pos = first;
|minthreadstoarchive = 1
while (pos <= last) {
|counter = 2
if ((pos == first) || ((*pos) >= *(pos - 1)))
|archive = Talk:Sorting algorithm/Archive %(counter)d
++pos;
}}
else {
std::iter_swap(pos, pos+1);
--pos;
}
}
 
Is this a genuine question about the quality of your code? If so, I'd probably suggest posting on StackExchange or something. <!-- Template:Unsigned IP --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/2605:6000:1522:400B:10FB:405:731E:8F1B|2605:6000:1522:400B:10FB:405:731E:8F1B]] ([[User talk:2605:6000:1522:400B:10FB:405:731E:8F1B#top|talk]]) 15:59, 4 October 2017 (UTC)</small> <!--Autosigned by SineBot-->
 
== Slowsort ==
Line 144 ⟶ 139:
 
I don't think that's true. If quick & dirty is required, one can implement Quicksort in a single line as in [http://en.literateprograms.org/Quicksort_(Python)#In_one_line_of_code]. For sorting of short sub-lists, I have observed variants on [[Insertion sort]] much more often than Bubble sort. For the case of finite lengths on those sub-lists, optimal compare-and-swap sequences are known for lists with a maximum length of at least 47 items, probably more. I think there's even a sequence on [[On-Line Encyclopedia of Integer Sequences|Sloane's]] for that, can't seem to find it right now. <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/129.13.72.197|129.13.72.197]] ([[User talk:129.13.72.197|talk]]) 16:17, 10 July 2010 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
== How bad is this code ==
template <class iterator> void gnome(iterator first, iterator last){ // O(n^2)
iterator pos = first;
while (pos <= last) {
if ((pos == first) || ((*pos) >= *(pos - 1)))
++pos;
else {
std::iter_swap(pos, pos+1);
--pos;
}
}
}
 
[[User:Veganfanatic|Veganfanatic]] ([[User talk:Veganfanatic|talk]]) 21:00, 9 August 2010 (UTC)
 
Is this a genuine question about the quality of your code? If so, I'd probably suggest posting on StackExchange or something. <!-- Template:Unsigned IP --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/2605:6000:1522:400B:10FB:405:731E:8F1B|2605:6000:1522:400B:10FB:405:731E:8F1B]] ([[User talk:2605:6000:1522:400B:10FB:405:731E:8F1B#top|talk]]) 15:59, 4 October 2017 (UTC)</small> <!--Autosigned by SineBot-->
 
==Joshua Kehn blog==