I'm given a question as such:
How many floating point multiplications are performed when each of the
following code fragments is executed? Express your answers in terms of n, n>= 10.
for(i=0; i<n*n; i++)
for(j=0; j<=i;j++)
a[i][j] = a[i][j]*0.125;
This is for my discrete math class, I'm not sure about how to tackle such a question, any ideas?
Outer loop is executed $n^2$ times.
Inner loop is executed $1, 2, \dots, n^2 + 1$ times.
Therefore, in total there are $\frac{1}{2} (n^2 + 1)(n^2 + 2)$ floating point multiplications.