Selection sort algorithm – Sorting algorithm – Program


Selection sort algorithm is where where we will find lowest value in collection and put it at first place till the collection is sorted.

For example lets say our collection is 4 ,7 ,3,8,2

Step 1:  2,4,7,3,8

Step 2: 2,3,4,7,8

And it will continue till 5 steps for each five numbers. It does not matter whether the array is sorted or not. Hence the Worst case scenario selection sort performance is O(n*n). Best case performance is also same. Hence it is advisable to not use this algorithm to sort big data. Its useful to sort big size files with small keys.

Algorithm is as follows:

for i 1 to n-1 do
min j i;
min x A[i]
for j i + 1 to n do
If A[j] < min x then
min j j
min x A[j]
A[min j] A [i]
A[i] min

3 thoughts on “Selection sort algorithm – Sorting algorithm – Program

  1. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three emails with the same comment. Is there any way you can remove people from that service? Thanks!

  2. Incredible! This blog looks just like my old one! It’s on a completely different subject but it has pretty much the same layout and design. Outstanding choice of colors!

Leave a Reply

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