Skip to content
Official PYQ · 2014

GATE CS 2014 Set 3 Q11 — Local Optimization

Explain with AI
The minimum number of arithmetic operations required to evaluate the polynomial P(X)=X5+4X3+6X+5P(X) = X^5+4X^3+6X+5 for a given value of XX, using only one temporary variable is ______.
View worked solution

Answer: 7

To evaluate the polynomial P(X)=X5+4X3+6X+5P(X) = X^5 + 4X^3 + 6X + 5 using only one temporary variable tt, we can restructure the polynomial to minimize the number of arithmetic operations (multiplications and additions).

We can rewrite P(X)P(X) in the following nested form:

P(X)=(((X2+4)XimesX+6)X+5)P(X) = (((X^2 + 4)X imes X + 6)X + 5)

Now, let us write the step-by-step evaluation sequence using a single temporary variable tt:

  1. t=XimesXt = X imes X    (Multiplication 1: t=X2t = X^2)
  2. t=t+4t = t + 4    (Addition 1: t=X2+4t = X^2 + 4)
  3. t=timesXt = t imes X    (Multiplication 2: t=X3+4Xt = X^3 + 4X)
  4. t=timesXt = t imes X    (Multiplication 3: t=X4+4X2t = X^4 + 4X^2)
  5. t=t+6t = t + 6    (Addition 2: t=X4+4X2+6t = X^4 + 4X^2 + 6)
  6. t=timesXt = t imes X    (Multiplication 4: t=X5+4X3+6Xt = X^5 + 4X^3 + 6X)
  7. t=t+5t = t + 5    (Addition 3: t=X5+4X3+6X+5t = X^5 + 4X^3 + 6X + 5)

Counting the operations:

  • Number of multiplications = 44
  • Number of additions = 33

Thus, the minimum number of arithmetic operations required is 4+3=74 + 3 = 7.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Local Optimization questions