Abstract data type 3. (12 points) Consider an abstract data type (ADT) for polyn
ID: 3027973 • Letter: A
Question
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 9Explanation / Answer
(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)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.