Pseudocode func Selection(s []int) { for i := 0; i < len(s); i++ { min := s[i] for j := i + 1; j < len(s); j++ { if s[j] < min { min = s[j] } } s[i] = min } } Relation to Heapsort Heapsort is just a selection sort backed by a heap rather than array Properties Worst TimeAverage TimeBest TimeWorst SpaceAverage SpaceStabilityAdaptiveΞΈ(N2)ΞΈ(N2)ΞΈ(N)ΞΈ(1)ΞΈ(1)Not StableNot Adaptive References Selection sort - Wikipedia Algorithms (4th ed). Robert Sedgewick, Kevin Wayne Introduction to Algorithms (4th ed). Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein Π‘ΠΎΡΡΠΈΡΠΎΠ²ΠΊΠ° Π²ΡΠ±ΠΎΡΠΎΠΌ - ΠΠ»Π³ΠΎΡΠΈΡΠΌΠΈΠΊΠ° 29.2 Selection Sort & Heapsort | CS61B Textbook