previous
|
index
|
next
Selection Sort
Start with
n
unsorted numbers
Scan
n
numbers for largest; remove and store it
Scan
n-1
numbers for second largest; remove and store it next to largest
Scan
n-2
numbers for third largest; remove and store it next to second largest
Continue till no more numbers to scan
Example:
Unsorted
Sorted
2
6
3
8
5
4
1
7
2
6
3
5
4
1
7
8
2
6
3
5
4
1
7
8
2
3
5
4
1
6
7
8
2
3
4
1
5
6
7
8
2
3
1
4
5
6
7
8
2
1
3
4
5
6
7
8
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
See the algorithm for sorting numbered cards on page 77.
previous
|
index
|
next