Skip to content

Latest commit

 

History

History

SelectionSort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Selection Sort

Algorithm type: Sorting algorithm
Can work in-place: No
Stable: Stable if the algorithm takes the first minimum, when two equal minimal numbers occur.
Time complexity: O(n2)

Pseudocode

function sort(inputValues: List)
   insertIndex ← 0
   for i ← 0 to |inputValues| -1 do
      min ← i
      for j ← i + 1 to |inputValues| do
         if inputValues[j] < inputValues[min] then min ← j
      end for
      interchange inputValues[min] and inputValues[insertIndex]
      insertIndex ← insertIndex + 1
   end for
   return inputValues
end function

Animation

Go to animation

© Marc Auberer 2020