Open In App

Time and Space complexity analysis of Selection Sort

The Selection sort algorithm has a time complexity of O(n^2) and a space complexity of O(1) since it does not require any additional memory space apart from a temporary variable used for swapping.

Time Complexity Analysis of Selection Sort:

The time complexity of the Selection sort remains constant regardless of the input array’s initial order. At each step, the algorithm identifies the minimum element and places it in its correct position. However, the minimum element cannot be determined until the entire array is traversed.

Breakdown for Time Complexity for Selection Sort:

Number of iterations                        

Comparisons                                           

1st

(n-1)

2nd

(n-2)

3rd

(n-3)

……..

……..

last

1

Auxiliary Space Complexity Analysis of Selection Sort:

Article Tags :