Selection sort is an in-place comparison sorting algorithm. It has an O(n²) time complexity, which makes it inefficient on large lists, and generally performs worse than the similar insertion sort.
Worst complexity : n²
Average complexity : n²
Best complexity : n²
stable : No
Algorithm
Idea
For every iteration we find the minimum element and swap it Example: step 1 : Extract minimum element in the array and swap it with element at index 0 , now we have minimum element at index 0 step 2 : Extract minimum element from the remaining list of elements (look for minimum element in the index locations 1 to end ) and swap it with element at index 1 step 3 : Extract minimum element from the remaining list of elements (look for minimum element in the index locations 2 to end ) and swap it with element at index 2 ………………. continue till the end of iteration
We accomplish Selection sort by creating two utility methods , one gets the minimum index position during every iteration and second helps us swap elements. We can use Iterative or Recursive implementation , here it’s done in both ways