The selection sort algorithm sorts an array by repeatedly finding the smallest element from unsorted array and pushing it to the beginning. Two subarrays are maintained during the execution of the script. One of the subarrays is in a sorted state while the other is in a sorted state. After each iteration of the for loop the sorted list is searched for the next correct element which is then pushed onto the sorted subarray.
Worst case performance : О(n^2) comparisons and O(n)swaps Best case performance : O(n^2) comparisons and O(n) Swaps Average performance: О(n^2) comparisons and O(n) Swaps Worst-case space complexity:О(n) total, O(1) auxiliary