Can someone help me with this Im not sure what this is askin

Can someone help me with this? I\'m not sure what this is asking, nor do I know how to do it. I put comments on what i think each is but im not exactly sure..

Algorithm of:

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

{

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

{

}

} // O(n^2) ?
will result in a number of iterations of given by the expression:

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

There is no code to write, the answer is text expressing the following:

Reduce the above series expression to an algebraic expression, without summation.

After determining the algebraic expression express the performance in Big O Notation.

Solution

So the summation is n+(n-1)+(n-2)+(n-3)+.....+1+0

This is equivalent to 1+2+3+4+5+6+7+8+......+n

Now this is an A.P. with number of terms=n

SUM=n/2(1+n)= n/2+n2/2 (Algebraic expression)

THEREFORE IT IS O(n2)

Can someone help me with this? I\'m not sure what this is asking, nor do I know how to do it. I put comments on what i think each is but im not exactly sure.. A

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site