Sitemap

SELECTION SORT

Feb 14, 2024

--

Selection sort is a sorting algorithm that repeatedly finds the minimum (or maximum, depending on your sorting needs) element from an unsorted list and swaps it with the first element of the unsorted list. This process continues until the entire list is sorted.

    Get Samoonalina’s stories in your inbox

    Join Medium for free to get updates from this writer.

  1. Initialize: Consider the entire list as unsorted initially.
  2. Find the minimum: In each iteration, find the index of the minimum element in the unsorted portion of the list.
  3. Swap: Swap the minimum element with the first element of the unsorted portion.
  4. Reduce unsorted section: Shrink the unsorted portion by one element (now starting from the second element).

--

--