Exercises 36—39 refer to the following algorithm to compute the value of a real polynomial.
Algorithm 11.3.3 Term-by-Term Polynomial Evaluation
[This algorithm computes the value of a polynomial by computing each term separately, starting with , and adding it to an accumulating sum.]Input: n [a nonnegative inreger],
[an array of real numbers], x [a real number]Algorithm Body:
for to n for to i next j next i
Output: polyval [a real number] 36. Trace Algorithm 11.3.3 for the input , and .
Trace stated algorithm for the input , and .
The tracing is tabulated below.
Complete the first column,
is given as
is given. is given as .
, this is given therefore
goes from to , therefore at the start
, is given. Therefore when , .
goes from to , at the start . Therefore .
Completing column 2,
Then we substitute ,
, Thus we update the second column,
Completing column 3,
When , . Now we substitute values to this equation.
, We update the 3rd column as
Now the loop is over and we move on to the next , , we update that on the 3rd column
Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!Get Started