Selection Sort

Selection sort is essentially the opposite of insertion sort in the way it works. Insertion starts at the left side of the array and selection starts at the right. It performs best when the array is reverse sorted. However, it does not perform well compared to any other algorithm case.

Asymptotic Complexity

$O(n^2)$

Pseudo Code

sort:
    // side effect: rearranges the values in A
    A = input array

    for i = 0 to num of items in A - 1:
        lowest = A[i]

        for j = i + 1 to num of items in A:
            if lowest > A[j]:
                lowest = A[j]

        swap lowest and A[i]

Source Code

Full Repo

Relevant Files:

Click here for build and run instructions