I was given a project to do, but I don't understand this notation and am rather confused, so I don't even know where to get started. I am supposed to be using the clock function to see how long it takes for the code below to finish running.
Prefix Averages (Quadratic): The following algorithm computes prefix averages in quadratic time by applying the definition.
Algorithm prefixAverages1(X, n)
Input array X of n integers
Output array A of prefix averages of X
A ← new array of n integers
for i ← 0 to n − 1 do
s ← 0
for j ← 0 to i do
s ← s + X[j]
A[i] ← s / (i + 1)
return A
This is what I have.
#include <iostream>
#include <time.h>
#include <algorithm>
using namespace std;
const int SIZE = 900000;
int prefixAverages(int x[], int n);
int prefixAverages2(int y[], int n);
int main()
{
clock_t t;
int x[SIZE];
int y[SIZE];
t = clock();
prefixAverages(x, SIZE);
return 0;
}
int prefixAverages1(int x[], int n)
{
}
I believe I can do what I am asked to do, but have no idea what that notation means.