Running Time of Selection Sort

Thread Starter

zulfi100

Joined Jun 7, 2012
656
upload_2016-1-19_23-12-7.png
Hi,
In the above image, I cant understand why the running time of inner loop is n*(n-1)/2? I am able to understand n* (n-1) but I cant understand why are we dividing by 2? Can some body please guide me.

Zulfi.
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
I am able to understand this. Actually the formula for sum of numbers from 1 to n is : ( n * (n+1))/ 2.

Zulfi.
 
Top