previous |
start |
next
Selection Sort
- Selection sort is based upon finding the
minimum value in a range of indices and placing that value at the
front of the vector.
- Example: Suppose we start with the following
vector.
- The smallest element is 5, so we place it in
the first location in the array. However we cannot lose the 11, so
these two elements are swapped.
- Now take the minimum of the remaining entries
a[1] ... a[4]. That value is in the correct place, so no swapping
is done.
- Repeat the process over the unsorted
region.
- Continue until the unprocessed region has
length 1. You are done.
previous |
start |
next