Need help understanding how the second loop is executed, I know for the second loop you would multiply by the first loop. First I count the number of instructions and then apply big-oh notation. This is my approach: would j=2*n be executed 2n times, j>=1 n+1, and j-- n times? New to big-oh notation and can't seem to find a list of 'for loops' examples anywhere, would love the feedback and information on where to practice more.
acc=10 \\ 1
for(i=5;i<=n/2;i++) \\ 1+n/2+n = (1+3n/2)
for(j=2*n; j>=1; j--) \\ (1+3n/2)(2n+n+1+n)
acc -= j + acc++; \\ (1+1+1) (2n+n+1+n)
//?j=2*nis executed once;j>=1is executed 2*n+1 times,j--is executed 2*n times. But you don't need to be that precise with the counting. k*n is a linear complexity, i.e. O(n).n/2 - 5instead of1+3n/2).