Run Time Analysis

QUESTION: Hello, today i am practicing run time analysis problems. However, i am confused on how to solve recursive problems that work with 'n'. I am confused on how to solve for the "for loops". Any help would be appreciated.

Example Below:

Sum = 0;
for(i=1 to (n-1)
for(j=1 to (i-1)
Sum = Sum + i*j;

I am trying to find the total.
So far i have...

Line 1 = 1
Line 2 = n or is it n-1?
Line 3 =
Line 4 =
Total = 1 + n +...+...

here is what i think the answer for line 3 should be? 'n' OR 2n OR n*n ???
Last edited on
Topic archived. No new replies allowed.