In the worst case, the total number of comparisons for Selection Sort is closest to:
n^2/2
n
n-1
n^2
n^2/4
Selection Sort's implementation is made up of two nested for loops.
The outer for loop is executed n-1
times.
The inner for loop is executed n-i
times.
The total cost is the sum of i
's
for i
goes from 1 to n
.