0
Can someone teach me how to use Selection Sort?
4 Réponses
+ 1
But why? It's really inefficient, just use quick sort, it's efficient and easy to program.
+ 1
Anyways, here is selection sort:
/* a is the array to sort, n its length */
for(int i = 0; i < n - 1; i++){
int m = i;
for(int t = i + 1; t < n; t++){
if(a[t] > a[m]){
m = t;
}
}
swap(a + i, a + m); /* swaps a[i] and a[m], you don't have to use a function for this */
}
Do you know how it works or do you want a quick explanation?
0
uh yes.. can u explain on how it works? ^_^ thank u
0
https://youtu.be/f8hXR_Hvybo
This video will probably explain it better than I could, but if you still have questions feel free to ask me!