The GATE Grind

GATE 2014 CS (CS3) – Question 21

Algorithms · Asymptotic Analysis and Time/Space Complexity · 1 mark · Numerical answer

Find the minimum arithmetic operations needed to evaluate $P(X)=X^5+4X^3+6X+5$ for given X, using only one temporary variable.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 7 to 7

Explanation

Use the form((X²+4)X²+6)X+5. Compute the first X², add4, recompute X²for its multiplication, add6, multiply byXand add5. This uses four multiplications and three additions, **7operations**, with one stored temporary. It improves on ordinary Horner treatment of the zero coefficients.