3.1 Matrix addition Let A be an N x N matrix initialized by arbitrary values. Suppose that we have to add N submatrices to A in the following manner:
for k := 1 to N do read (R1;R2;C1;C2; V ); for i := R1 to R2 do for j := C1 to C2 do A[i][j] := A[i][j] + V ; end end end
For each of the submatrix, 1 <= R1 <= R2 <= N, 1 <= C1 <= C2 <= N and V 2 R. Furthermore, (R1, R2, C1, C2, V ) are dierent from submatrix to submatrix. It is obvious that the above algorithm takes O(N3) in the worst case. Design an algorithm with better time complexity while achieving the same task.