Compute the sum of two


Implement the ADT polynomial that Exercise 9 in Chapter 1describes by using a list. Then write a program that adequately demonstrates your new class.

Exercise 9:

Consider the ADT polynomial-in a single variable x -whose operations include the following:

1051_4a140530-7e9b-468e-9a0b-5ef9d1402e4b.png

For this problem, consider only polynomials whose exponents are nonnegative integers. For example, p = 4 x5 + 7 x3 - x2 + 9

The following examples demonstrate the ADT operations on this polynomial.

P .degree() is 5 (the highest power of a term with a nonzero coefficient)

p .coefficient(3) is 7 (the coefficient of the x3 term)

p .coefficient(4) is 0 (the coefficient of a missing term is implicitly 0)

p. change Coefficient(-3, 7) changes the polynomial p to -3 x7 + 4 x5 + 7 x3 - x2 + 9

Using these ADT operations, write statements to perform the following tasks:

a. Display the coefficient of the term that has the highest power.

b. Increase the coefficient of the x3 term by 8.

c. Compute the sum of two polynomials.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Compute the sum of two
Reference No:- TGS01422718

Expected delivery within 24 Hours