Selection Sort [in progress]
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.
1) The subarray which is already sorted. 2) Remaining subarray which is unsorted.
Selection sort is very much like finding the minimum element in an array. The inner loop for selection sort does just that.
When the inner loop find the minimum of arr[i..n] at pos x, we do swap(arr[i]. arr[x])
E.g. arr[] = 64 25 12 22 11
/ Find the minimum element in arr[0…4] // and place it at beginning 11 25 12 22 64
// Find the minimum element in arr[1…4] // and place it at beginning of arr[1…4] 11 12 25 22 64
// Find the minimum element in arr[2…4] // and place it at beginning of arr[2…4] 11 12 22 25 64
// Find the minimum element in arr[3…4] // and place it at beginning of arr[3…4] 11 12 22 25 64