Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

GATE | GATE-CS-2006 | Question 60

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Consider the following C code segment. 

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

Which one of the following is false?


The code contains loop invariant computation


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


There is scope of strength reduction in this code


There is scope of dead code elimination in this code

Answer: (D)


Question asks about false statement

4*j is common subexpression elimination so B is true.

5*i can be moved out of inner loop so can be i%2. 
Means, A is true as we have loop invariant computation.

Next, 4*j as well as 5*i can be replaced with a = - 4;
before j loop then a = a + 4; where 4*j is computed,
likewise for 5*i. C is true as there is scope of strength 

By choice elimination, we have D.

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 17 Sep, 2021
Like Article
Save Article
Similar Reads