Big O Notation help

Algorithm of:

for ( j = 0; j < n; j++ )

{

for ( k = j; k < n; k++ )

{

<some operation>

}

}
will result in a number of iterations of <some operation> given by the expression:

<number of iterations> = n + (n-1) + (n-2) + (n-3) + ........ + (n - n)

Reduce the above series expression to an algebraic expression.

After determining the algebraic expression express the performance in Big O Notation.
I will give you a hint.

1
2
3
4
    n + (n-1) + (n-2) + (n-3) + ... + 1
  + 1 +    2  +    3  +    4  + ... + n

= ?


What is n + (n-1) + (n-2) + (n-3) + ... + 1 in terms of ?


Topic archived. No new replies allowed.