   Chapter 11.3, Problem 37ES ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193

#### Solutions

Chapter
Section ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193
Textbook Problem
1 views

# 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 a [ n ] x n + a [ n − 1 ] x n − 1 + ⋯ + a [ 2 ] x 2 + a [ 1 ] x + a [ 0 ] by computing each term separately, starting with a [ 0 ] , and adding it to an accumulating sum.]Input: n [a nonnegative inreger], a [ 0 ] ,   a [ 1 ] ,   a [ 2 ] ,   … a [ n ] [an array of real numbers], x [a real number]Algorithm Body: p o l y v a l   : = a [ 0 ] for i : = 1 to n t e r m   : = a [ i ] for j : = 1 to i t e r m : = t e r m ⋅ x next j p o l y v a l : = p o l y v a l + t e r m next i [ A t   t h i s   p o i n t   p o l y v a l = a [ n ] x n + a [ n − 1 ] x n − 1 + ⋯ + a [ 2 ] x 2 + a [ 1 ] x + a [ 0 ] . ] Output: polyval [a real number] 37. Trace Algorithm 11.3.3 for the input n = 2 ,   a [ 0 ] = 5 ,   a [ 1 ] = − 1 ,   a [ 2 ] = 2 , and x = 3

To determine

Trace algorithm 11.3.3 for the input n=2, a=5,a=1,a=2 and x=3

Explanation

Information given:

n=2, a=5,a=1,a=2 and x=3

Calculation:

 n 2 a 5 a -1 a 2 x 3 polyval 5 2 20 i 1 2 term -1 -3 2 6 18 j 1 1 2

Complete the first column, n is given as 2

a=5,a=1,a=2 is given. x is given as 3.

polyval=a, this is given therefore polyval=5

i goes from 1 to n, therefore at the start i=1

term=a[i], is given. Therefore when i=1, term=1.

j goes from 1 to i, at the start i=1. Therefore j=1.

Completing column 2, Then we substitute j=1 ,

term=termx

term=(1)3=3 (because term=1 and x=3), Thus we update the second column, term=3

Completing column 3,

When term=3, polyval=polyval+term

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started 