0

Can someone teach me how to use Selection Sort?

18th Feb 2017, 2:49 PM
Justine
Justine - avatar
4 Respuestas
+ 1
But why? It's really inefficient, just use quick sort, it's efficient and easy to program.
18th Feb 2017, 3:25 PM
Robobrine
Robobrine - avatar
+ 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?
18th Feb 2017, 3:40 PM
Robobrine
Robobrine - avatar
0
uh yes.. can u explain on how it works? ^_^ thank u
18th Feb 2017, 3:47 PM
Justine
Justine - avatar
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!
18th Feb 2017, 4:09 PM
Robobrine
Robobrine - avatar