Selection sort analysis
Iteration No. times array comparison performed
of outer loop during this iteration of outer loop
So number of comparisons is
1 + 2 + 3 + � +(n-2) + (n-1) = n * (n-1) / 2 = n2/2 - n/2
As n gets large, the term n2 dominates. We say the number if comparisons is proportional to n2 and that this is a quadratic algorithm.