*** ICS 665 Project ***

Selection Sort Algorithm Description

The Selection Sort algorithm finds the MINIMUM (Ascending Order) or MAXIMUM (Descending Order) element of the (sub)array and swaps it with the PIVOT or ("ANCHOR") element. The code for the algorithm is as follows:

The Selection Sort Algorithm (Descending Order)

The following algorithm is based on the following principle:
1.Select the item with the maximum key
2.Exchange it with the first item data[0]
Then repeat these operation with the remaining n-1 items,
then with n-2 items, until only one item-the smallest-is left.
        //data is an array of size n
        for (pivot = 0; pivot < n-1; pivot++) {
          max_index = pivot;
          for (j = (pivot + 1); j < n; j++)
              if (data[j] > data[max_index])
                 max_index = j;
          swap(data[pivot], data[max_index]);

Table of Contents for Main Project :

  • Implementation

    Go back to Frog's Home Page