Selection sort also divides sequence in two parts. Sorted part and unsorted part.
Initially sorted kept doesn’t contain any element and the unsorted section contains the whole sequence. In every step the minimum element of the unsorted section is added to the sorted section by swapping the first element of unsorted section by the minimum element. Thus with every iteration, the size of the sorted sequence keeps on increasing. This process is continued until the length of sorted sequence becomes equal to the length of the sorted sequence.
Here is the visualisation of selection sort:
Implementation of selection sort is as follows:
Time Complexity : O( n2 )
Output
So that’s it for this article we will be coming up with our next article on further topics very soon till then keep learning, keep coding, keep reading and keep improving !!
Happy Coding 😊
By Programmers Army