Selection sort is a sorting algorithm, a comparison sort that works as follows:
1. find the minimum value in the list
2. swap it with the value in the first position
3. sort the remainder of the list (excluding the first value)
Example:
a=[9,7,5,3,1,0,4,6,8]
0 is lowest value, swap with 9
a=[0,7,5,3,1,9,4,6,8]
1 is lower than 7, swap these numbers
a=[0,1,5,3,7,9,4,6,8]
3 is lower than 5, swap these two numbers
a=[0,1,3,5,7,9,4,6,8]
...
until the list is sorted.
2006-09-23 09:45:02
·
answer #1
·
answered by Gordo J 2
·
0⤊
0⤋