Skip to content
Related Articles
Open in App
Not now

Related Articles

ISRO | ISRO CS 2011 | Question 3

Improve Article
Save Article
  • Last Updated : 14 May, 2018
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!