Selection Sort

Selection Sort is a simple comparison-based sorting algorithm. It works by dividing the input list into two parts: a sorted sublist and an unsorted sublist. The algorithm repeatedly finds the minimum element from the unsorted sublist and moves it to the end of the sorted sublist.

Steps:

  1. Set the first element as the minimum
  2. Compare this with the remaining elements to find the actual minimum
  3. Swap the minimum with the first element
  4. Move to the next element and repeat until the array is sorted

Time Complexity

Best: O(n²)

Average: O(n²)

Worst: O(n²)

Space Complexity

O(1)

Array length:

7

Speed:

Canvas is not supported in your browser. Please use Edge or Chrome.