In computer science, selection sort is an in-place comparison sorting algorithm. It is inefficient on large list. It has a performance wore than Insertion sort. But at some case it proves its simplicity and advantages.
The time complexity of the selection sort is the same in all cases. At every step, you have to find the minimum element and put it in the right place. The minimum element is not known until the end of the array is not reached.
ALGORITHM
1.) First of all take a list, and look for the minimum element.
2.) Place that minimum element at the first position and the first element at the index of that minimum element.
3.) Now fix the minimum at first position, now look for the minimum element in the list except the first element because it is already sorted. Now place the minimum element on second position and that second element at the index of that minimum element.
4.) Go on upto the last element and place the minimum elements ahead.
5.) Print the resulted list.
DATA STRUCTURE
So this was the simple and easy algorithm and data structure of the SELECTION SORT. Hope you understand this sorting algorithm. Please share it with your friends. In the next tutorial, we will learn about the MERGE SORT.
Contact mail id - john.veer.utube@gmail.com
Contact us for any query
Thanks for reading !

Comments
Post a Comment