Consider the ADT polynomial—in a single variable x—whose operations include the following:
+degree():integer {query}
// Returns the degree of a polynomial.
+getCoefficient(in power:integer):integer
// Returns the coefficient of the xpower term.
+changeCoefficient(in newCoef:integer, in power:integer)
// Replaces the coefficient of the xpowet term
// with newCoef.
For this problem, consider only polynomials whose exponents are nonnegative integers. For example,
p = 4x5 + 7x3 - x2 + 9
The following examples demonstrate the ADT operations on this polynomial.
p .degree () is 5 (die highest power of a term with a nonzero coefficient)
p .getCoefficient (3) is 7 (the coefficient of the x3 term)
p .getCoefficient (4) is 0 (the coefficient of a missing term is implicidy 0)
p. changeCoefficient(-3, 7) produces the polynomial
p = -3x7 + 4x5 + 7x3 - x2 + 9
Using only the ADT operations provided, write statements to perform the following tasks:
a. Display the constant term (the coefficient for the x0 term).
b. Change each coefficient in the polynomial by multiplying them by 5.
с. For a given polynomial such as p = -3x7 + 4x5 + 7x3 - x2 + 9, display the expression in the form - 3x^7 +4x^5 + 7x^3 - lx^2 + 9.
d. Change the polynomial to its derivative—for example,p = -3x7 + 4x5 + 7x3 - x2 + 9 becomesp =-21x6 + 20x4 + 21x2 - 2xl.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.