Selection Sort Algorithm Description

The Selection Sort algorithm finds the MINIMUM 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

        //Input is an array of size == n
        for (i = 0; i < (n - 1); i++) {
          min_index = i;
          for (j = (i + 1); j < n; j++)
              if (Input[j] > Input[min_index])
                min_index = j;
          swap(Input[i], Input[min_index]);

Implementation of the Selection Sort

Source Program of the applet