A space-efficient quadratic sorting algorithms. [Time: Θ(n2), Space: O(1)]
Idea
The idea of selection sort is to iteratively select the smallest (or largest) item from the unsorted n items and swap to the first position. It takes O(k) swaps and Θ(k2) scans and comparisons for an array of k items.
Implementation
Below is an implementation of selection sort in golang.
package sorting |
References: