The **selection sort**
is a combination of searching and sorting.
**During each pass, the unsorted element
with the smallest (or largest) value is moved to its proper
position in the array. **
The number of times the sort passes through the array is
one less than the number of items in the array. In the
selection sort, the inner loop finds the next smallest (or
largest) value and the outer loop places that value into its
proper location.
Let's look at our same table of elements using
a selection sort for descending order. Remember, a "pass" is
defined as one full trip through the array comparing and if
necessary, swapping ** **elements. |