matrix360 0 Newbie Poster

hey i just need some help understanding how to do this question, i need to find the running time, and show it in algebra like "2i+2" and also in Big O notation such as O(n^2), the question also asks to state the number of additions and subtractions in the algorithm not to sure what its asking of that if anyone could help out it would be greatly appreciated.

Q1:

sum = 0; (1 assignment operation)
for (i = 0; i < n; i++) //(i=0 is 1 operation, i<n is n+1 operation, i++ is n operation)
for (j = 0; j < i; j++) //(here im lost j=0 is 1 operation, j<i runs from 0 to 0 im not sure what this is ??, j++ is i operation)
sum++; //( i operation as its contained in the second for loop)


Q2:

sum = 0;
for (i = 0; i < n; i++)
for (j = 0; j < i*i; j++) ( not to sure how to approach j< i*i)
for (k = 0; k < j; k++)
sum++;