Running Time of Selection Sort

Discussion in 'Homework Help' started by zulfi100, Jan 19, 2016.

  1. zulfi100

    Thread Starter Member

    Jun 7, 2012
    320
    0
    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.
     
  2. zulfi100

    Thread Starter Member

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

    Zulfi.
     
Loading...