Selection Sort

Overview

Selection sort works by iterating upward through an array, swapping the value in the current position with the smallest value in the remainder of the array.

Property Value
Best Case Ω(n2)
Worst Case O(n2)
Avg. Case O(n2)
Aux. Memory O(1)
Stable No
Adaptive No
Visualization selection-sort.gif

Loop Invariant

Selection sort has loop invariant P given by

A[0:i-1] is a sorted array of the i least elements of A.

Powered by Forestry.md