Implement the Selection Sort algorithm. Repeatedly find the minimum element from the unsorted part of the array and place it at the beginning.
Divide the array into sorted and unsorted halves. On each pass, find the minimum of the unsorted part and swap it with the first unsorted element.
- Outer loop i from 0 to n-2 marks the start of the unsorted portion.
- Find the index of the minimum element in arr[i..n-1].
- Swap arr[i] with arr[minIdx].
- After n-1 passes the array is fully sorted.
- Time Complexity: O(N^2) all cases
- Space Complexity: O(1) in-place