2
I have an A vector of size n. I have to calculate the partial sum of each element and write in the matrix B[i,j].
Pseudo-code shows a solution O(n 2);
For i = 1, 2, . . . , n
For j = i + 1, i + 2, . . . , n
B[i, j] <- A[i] + A[i+1] + ... + A[j];
Endfor
Endfor
Is there an O(n) or O(log n) solution? What would it be like?