Talk:Sorting algorithm: Difference between revisions

Content deleted Content added
How is this stable sort example?: The tables work fine, but the examples aren't illustrating the concept of stability
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 526:
This sort only works on a sequential set of numbers in some random permutation, using swaps to sort the set of numbers. The worst case number of swaps is n-1. Example code for when the set of number is {0, 1, ..., n-1} stored in an array a[]:
 
<sourcesyntaxhighlight lang="C">
void sort(void)
{
Line 534:
swap(a[i], a[a[i]]);
}
</sourcesyntaxhighlight>Several
[[User:Rcgldr|Rcgldr]] ([[User talk:Rcgldr|talk]]) 09:18, 27 April 2013 (UTC)
 
Line 541:
:: Given the constraint that the array of size n contains a permuted set of numbers {0, 1, ... , n-1}, the worst case number of swaps is n-1. I've since figured out that this algorithm can be expanded to sort an array based on a set of sorted indexes:
 
<sourcesyntaxhighlight lang="C">
// A is an array of size n
A[] = ... ;
Line 560:
}
}
</syntaxhighlight>
</source>
[[User:Rcgldr|Rcgldr]] ([[User talk:Rcgldr|talk]]) 01:04, 29 April 2013 (UTC)