Question: The following algorithms evaluate the polynomial p(x) = a_nx^n + a_n-1x^n-1 + ...+a_1 x + a_0 at a point x = c in two different

 The following algorithms evaluate the polynomial p(x) = a_nx^n + a_n-1x^n-1

The following algorithms evaluate the polynomial p(x) = a_nx^n + a_n-1x^n-1 + ...+a_1 x + a_0 at a point x = c in two different ways. procedure polynomial(c, a_0, a_1, ..., a_n) power:= 1 y =a_0 for i:= 1 to n power:= power * c y:=y + a_i * power return y procedure Horner(c, a_0, a_1, ..., a_n) y:=a_n for i:= 1 to n y:= y * c + a_n-i return y Evaluate 3x^2 + x + 1 at x = 2 using each of the two procedures. Show your steps. Exactly how many multiplications and additions are used by each of the two procedures for a polynomial of degree n at x = c? (Do not count additions used to increment for-loops). Which procedure is more efficient

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!