I've written a piece of java code that when given an array (arrayX), works out the prefix averages of that array and outputs them in another array (arrayA). I am supposed to count the primitive operations and calculate the Big-O notation (which i'm guessing is the overall number of calculations). I have included the java code and what I believe to be the number of primitive operations next to each line, but I am unsure whether I have counted them correctly. Thanks in advance and sorry for my inexperience, i'm finding this hard to grasp :)
double [] arrayA = new double [arrayX.length]; *(3 Operations)*
for (int i = 0; i < arrayX.length; ++i) *(4n + 2 Operations)*
{
double sum = arrayX[i]; *(3n Operations)*
for (int j = 0; j < i; ++j) *(4n^2 + 2n Operations)*
{
sum = sum + arrayX[j]; *(5n^2 Operations)*
}
arrayA[i] = sum/(i+1); *(6n Operations)*
}
return arrayA; *(1 Operation)*
Total number of operations: 9n^2 +15n + 6