I've created a method (based on pseudocode I found online) to compute prefix averages for an array but I'm not sure I've satisfied the requirement. 

**The requirement is:** 

> 
> Given an array a[1…n] of n numbers, compute another array b[1…n] also
>  of length n such that b[i] is the average of a[0]…a[i], for 0 <= i <=
>  n. 
> 
> 
> 

I looked around and found pseudocode for linear and quadratic versions of prefix average methods, and created my own implementation of each. 

**Here is the linear version:** 

```
public static double[] prefixAverages1 (double[] n) {
        double b[] = new double[n.length]; 
        double s = 0;    
        for (int i = 0; i < n.length; i++) {
            s += n[i]; 
            b[i] = s/(i+1);
        }
        return b; 
}

```

**Here is the quadratic version:** 

```
public static double[] prefixAverages2 (double[] n) {
        double b[] = new double[n.length];  
        for (int i = 0; i < n.length; i++) {
            double t = 0;
            for (int j = 0; j <= i; j++) {
                t += n[j];
            }
            b[i] = t/(i+1);
        }
        return b;
}

```

**My Question:** 

Do both of these functions satisfy the requirement and if so, which one is better?