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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
14 May, 2018
Like Article
Save Article