Selection Sort Algorithm

Selection Sort is a comparison-based sorting algorithm. It sorts an array by repeatedly selecting the smallest (or largest) element from the unsorted portion and swapping it with the first unsorted element. This process continues until the entire array is sorted.

  1. First we find the smallest element and swap it with the first element. This way we get the smallest element at its correct position.
  2. Then we find the smallest among remaining elements (or second smallest) and swap it with the second element.
  3. We keep doing this until we get all elements moved to correct position.

 

By Md Jakaria Nur

Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *