Selection Sort

In selection sort, the idea of the algorithm is to find the smallest unsorted element and add it to the end of the sorted list. 

  1. Select the first smallest element and swap it with the first unsorted element(1,4) 
43125
  1. Select the first smallest element and swap it with the first unsorted element(2,3) 
13425
  1. Select the first smallest element and swap it with the first unsorted element(3,3) 
12345

Algorithm:

  • Repeat until no unsorted elements remain:
  • Search the unsorted part of the data to find the smallest value
  • Swap the smallest found value with the first element of the unsorted part