Two programmes are asked to write a program to sum the rows of a 2X2 matrices stored in the array A.
Ravi writes the following code (Code A):
for n = 0 to 1
sumRow1[n] = A[n][1] + A[n][2]
end
Rupali writes the following code (Code B):
sumRow1[0] = A[0][1] + A[0][2]
sumRow1[1] = A[1][1] + A[1][2]
Comment upon these codes (Assume no loop-unrolling done by compiler):
Option 1 : Code A will execute faster than Code B.
Option 2 : Code B will execute faster than Code A
Option 3 : Code A is logically incorrect.
Option 4 : Code B is logically incorrect.
Answer: Option 2