Open In App

ISRO | ISRO CS 2011 | Question 3

Like Article
Like
Save
Share
Report

In compiler terminology reduction in strength means
(A) Replacing run time computation by compile time computation
(B) Removing loop invariant computation
(C) Removing common subexpressions
(D) replacing a costly operation by a relatively cheaper one


Answer: (D)

Explanation: Strength Reduction is a compiler optimization in which costly operations are replaced by cheaper ones. Example: Exponentiation is replaced by multiplication and multiplication is in return replaced by addition.
The following code is having multiplication operator:

a = 10;
for (i = 0; i < X; i++)
{
    Z[i] = a * i;
}

This code can be replaced by the following code by replacing the multiplication with addition.

a = 10;
k = 0;
for (i = 0; i < X; i++)
{
    Z[i] = k;
    k = k + a;
}

So, option (D) is correct.

Quiz of this Question


Last Updated : 14 May, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads