BuyFindarrow_forward

Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193

Solutions

Chapter
Section
BuyFindarrow_forward

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[0]=5,a[1]=1,a[2]=2 and x=3

Explanation

Information given:

n=2, a[0]=5,a[1]=1,a[2]=2 and x=3

Calculation:

n 2
a[0] 5
a[1] -1
a[2] 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[0]=5,a[1]=1,a[2]=2 is given. x is given as 3.

polyval=a[0], 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

Chapter 11 Solutions

Show all chapter solutions add
Sect-11.1 P-5ESSect-11.1 P-6ESSect-11.1 P-7ESSect-11.1 P-8ESSect-11.1 P-9ESSect-11.1 P-10ESSect-11.1 P-11ESSect-11.1 P-12ESSect-11.1 P-13ESSect-11.1 P-14ESSect-11.1 P-15ESSect-11.1 P-16ESSect-11.1 P-17ESSect-11.1 P-18ESSect-11.1 P-19ESSect-11.1 P-20ESSect-11.1 P-21ESSect-11.1 P-22ESSect-11.1 P-23ESSect-11.1 P-24ESSect-11.1 P-25ESSect-11.1 P-26ESSect-11.1 P-27ESSect-11.1 P-28ESSect-11.2 P-1TYSect-11.2 P-2TYSect-11.2 P-3TYSect-11.2 P-4TYSect-11.2 P-5TYSect-11.2 P-6TYSect-11.2 P-1ESSect-11.2 P-2ESSect-11.2 P-3ESSect-11.2 P-4ESSect-11.2 P-5ESSect-11.2 P-6ESSect-11.2 P-7ESSect-11.2 P-8ESSect-11.2 P-9ESSect-11.2 P-10ESSect-11.2 P-11ESSect-11.2 P-12ESSect-11.2 P-13ESSect-11.2 P-14ESSect-11.2 P-15ESSect-11.2 P-16ESSect-11.2 P-17ESSect-11.2 P-18ESSect-11.2 P-19ESSect-11.2 P-20ESSect-11.2 P-21ESSect-11.2 P-22ESSect-11.2 P-23ESSect-11.2 P-24ESSect-11.2 P-25ESSect-11.2 P-26ESSect-11.2 P-27ESSect-11.2 P-28ESSect-11.2 P-29ESSect-11.2 P-30ESSect-11.2 P-31ESSect-11.2 P-32ESSect-11.2 P-33ESSect-11.2 P-34ESSect-11.2 P-35ESSect-11.2 P-36ESSect-11.2 P-37ESSect-11.2 P-38ESSect-11.2 P-39ESSect-11.2 P-40ESSect-11.2 P-41ESSect-11.2 P-42ESSect-11.2 P-43ESSect-11.2 P-44ESSect-11.2 P-45ESSect-11.2 P-46ESSect-11.2 P-47ESSect-11.2 P-48ESSect-11.2 P-49ESSect-11.2 P-50ESSect-11.2 P-51ESSect-11.3 P-1TYSect-11.3 P-2TYSect-11.3 P-3TYSect-11.3 P-1ESSect-11.3 P-2ESSect-11.3 P-3ESSect-11.3 P-4ESSect-11.3 P-5ESSect-11.3 P-6ESSect-11.3 P-7ESSect-11.3 P-8ESSect-11.3 P-9ESSect-11.3 P-10ESSect-11.3 P-11ESSect-11.3 P-12ESSect-11.3 P-13ESSect-11.3 P-14ESSect-11.3 P-15ESSect-11.3 P-16ESSect-11.3 P-17ESSect-11.3 P-18ESSect-11.3 P-19ESSect-11.3 P-20ESSect-11.3 P-21ESSect-11.3 P-22ESSect-11.3 P-23ESSect-11.3 P-24ESSect-11.3 P-25ESSect-11.3 P-26ESSect-11.3 P-27ESSect-11.3 P-28ESSect-11.3 P-29ESSect-11.3 P-30ESSect-11.3 P-31ESSect-11.3 P-32ESSect-11.3 P-33ESSect-11.3 P-34ESSect-11.3 P-35ESSect-11.3 P-36ESSect-11.3 P-37ESSect-11.3 P-38ESSect-11.3 P-39ESSect-11.3 P-40ESSect-11.3 P-41ESSect-11.3 P-42ESSect-11.3 P-43ESSect-11.4 P-1TYSect-11.4 P-2TYSect-11.4 P-3TYSect-11.4 P-4TYSect-11.4 P-5TYSect-11.4 P-1ESSect-11.4 P-2ESSect-11.4 P-3ESSect-11.4 P-4ESSect-11.4 P-5ESSect-11.4 P-6ESSect-11.4 P-7ESSect-11.4 P-8ESSect-11.4 P-9ESSect-11.4 P-10ESSect-11.4 P-11ESSect-11.4 P-12ESSect-11.4 P-13ESSect-11.4 P-14ESSect-11.4 P-15ESSect-11.4 P-16ESSect-11.4 P-17ESSect-11.4 P-18ESSect-11.4 P-19ESSect-11.4 P-20ESSect-11.4 P-21ESSect-11.4 P-22ESSect-11.4 P-23ESSect-11.4 P-24ESSect-11.4 P-25ESSect-11.4 P-26ESSect-11.4 P-27ESSect-11.4 P-28ESSect-11.4 P-29ESSect-11.4 P-30ESSect-11.4 P-31ESSect-11.4 P-32ESSect-11.4 P-33ESSect-11.4 P-34ESSect-11.4 P-35ESSect-11.4 P-36ESSect-11.4 P-37ESSect-11.4 P-38ESSect-11.4 P-39ESSect-11.4 P-40ESSect-11.4 P-41ESSect-11.4 P-42ESSect-11.4 P-43ESSect-11.4 P-44ESSect-11.4 P-45ESSect-11.4 P-46ESSect-11.4 P-47ESSect-11.4 P-48ESSect-11.4 P-49ESSect-11.4 P-50ESSect-11.4 P-51ESSect-11.5 P-1TYSect-11.5 P-2TYSect-11.5 P-3TYSect-11.5 P-4TYSect-11.5 P-5TYSect-11.5 P-1ESSect-11.5 P-2ESSect-11.5 P-3ESSect-11.5 P-4ESSect-11.5 P-5ESSect-11.5 P-6ESSect-11.5 P-7ESSect-11.5 P-8ESSect-11.5 P-9ESSect-11.5 P-10ESSect-11.5 P-11ESSect-11.5 P-12ESSect-11.5 P-13ESSect-11.5 P-14ESSect-11.5 P-15ESSect-11.5 P-16ESSect-11.5 P-17ESSect-11.5 P-18ESSect-11.5 P-19ESSect-11.5 P-20ESSect-11.5 P-21ESSect-11.5 P-22ESSect-11.5 P-23ESSect-11.5 P-24ESSect-11.5 P-25ESSect-11.5 P-26ES