void selectionSort(vector<int>& arr, int n) {
    for(int i=0 ; i<= n-2 ; i++){
        int min = i ;
        for(int j=i ; j<=n-1 ; j++){
            if(arr[j] < arr[min]){
                min = j ;
            }
        }
        swap(arr[i], arr[min]);
    }
}
Type Complexity
Time (Best) O(n²)
Time (Worst) O(n²)
Time (Average) O(n²)
Space O(1)

Why Is It Important?

  1. Performance Optimization:
  2. Scalability:
  3. Resource Constraints:
  4. Algorithm Comparison: