Consider the code segment: int i, j, x, y, m, n; n = 20; for (i = 0; i < n;…

ISRO Scientist/Engineer SC · December 2017 · Computer ScienceModified — slightly modified from the official paper; see the solution

Consider the code segment:

int i, j, x, y, m, n;
n = 20;
for (i = 0; i < n; i++) {
  for (j = 0; j < n; j++) {
    if (i % 2) {
      x += ((4 * j) + 5 * i);
      y += (7 + 4 * j);
    }
  }
}
m = x + y;

For this optimization analysis, assume that x and y were initialized before the segment and that the value assigned to m is used afterward.

Which one of the following is false?

  1. A.

    The code contains loop invariant computation

  2. B.

    There is scope of common sub-expression elimination in this code

  3. C.

    There is scope of strength reduction in this code

  4. D.

    There is scope of dead code elimination in this code

Attempted by 198 students.

Sign up free to check your answer

Sign up free

Explore the full course: Tpsc Assistant Technical Officer

Loading lesson…