VisuAl

Selection Sort

Generate Random Values

Enter the number of random values to generate

Input Your Own Values

Enter a list of numbers separated by a comma

Whats goin on?

Selection sort is an algorithm steps through an array and looks for the smallest value in the unsorted portion. Then the algorithm swaps the smallest value for the current position and moves onto the next. This process is repeated for every position in the array until the end, where the array can be presumed sorted.

Performance

Time complexity

Because each iteration has an additional iteration through the array forward, the time complexity of selection sort is

O(n^2)

Space complexity

Selection sort only needs one additional space in memory to perform the swap so its space complexity is

O(1)

More Info...