Abstract data type 3 12 points Consider an abstract data typ
Abstract data type
3. (12 points) Consider an abstract data type (ADT) for polynomials (in a single variable x whose operations include the following: int degree0 Returns the degree of the polynomial. int coefficient int power) Returns the coefficient of the xpower term. void changeCoefficient(int newCoefficient, int power) /Replaces the coefficient of the x term with newCoefficient power For this problem, consider only polynomials whose exponents are nonnegative integers. For example, 4x5 7x. x 9Solution
(a). a=q.degree()
q.coefficient(a)
(b) a=q.coefficient(3)-2
q.changeCoefficient(a,3)
(c) a=q.degree()
b=r.degree()
if (a>b)
x=a
else x=b
for(i=0, i++,i<=x )
s.coefficient(i)=q.coefficient(i)+r.coefficient(i)
