Answer:
a.) value of polynomial at x=2 is 15
b,) exactly 2 multiplications and 1 addition are used to evaluate the polynomial
Step-by-step explanation:
a.)
at x = 2,
3x²+x+1
with n = 2, a₀=1, a₁=1, a₂=3 with c=2,
firstly we set power =1
y=1
for the first time through the loop;
we have i = 1
the power increases to 2
y = 1+1*2
= 3
i =2
then going through the loop for the last time
power = 2x2 = 4
y = 3+(3*4)
= 15
we stop here because polynomial is of degree 2
b.
while passing through the loop, each pass requires that we do 2 multiplications and 1 addition. so for the for loop we have n iterations with total being 2n multiplications and n additions.