Menu

(Solved) : 3 12 Points Consider Abstract Data Type Adt Polynomials Single Variable X Whose Operations Q44106461 . . .

3. (12 points) Consider an abstract data type (ADT) for polynomials (in a single variable x) whose operations include the fol

3. (12 points) Consider an abstract data type (ADT) for polynomials (in a single variable x) whose operations include the following: int degree() // 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 power term with newCoefficient For this problem, consider only polynomials whose exponents are nonnegative integers. For example, p = 4x + 7×2 – y2 +9 The following examples demonstrate the ADT operations on the above polynomial. p.degree() is 5 (the highest power of a term with a nonzero coefficient) p.coefficient(3) is 7 (note that the coefficient of a missing term is implicitly 0) p.changeCoefficient(-3,7) produces the polynomial p=-3x + 4x + 7×3 – x2 + 9 Using these ADT operations, write C++ statements to perform the following tasks for an arbitrary polynomial q. 1. Display the coefficient of the term that has the highest power to the console output. 2. Decrease the coefficient of the x2 term by 3. 3. Compute the sum of two polynomials q and r. Place the result in a third polynomials that has been previously initialized to zero. Show transcribed image text 3. (12 points) Consider an abstract data type (ADT) for polynomials (in a single variable x) whose operations include the following: int degree() // 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 power term with newCoefficient For this problem, consider only polynomials whose exponents are nonnegative integers. For example, p = 4x + 7×2 – y2 +9 The following examples demonstrate the ADT operations on the above polynomial. p.degree() is 5 (the highest power of a term with a nonzero coefficient) p.coefficient(3) is 7 (note that the coefficient of a missing term is implicitly 0) p.changeCoefficient(-3,7) produces the polynomial p=-3x + 4x + 7×3 – x2 + 9 Using these ADT operations, write C++ statements to perform the following tasks for an arbitrary polynomial q. 1. Display the coefficient of the term that has the highest power to the console output. 2. Decrease the coefficient of the x2 term by 3. 3. Compute the sum of two polynomials q and r. Place the result in a third polynomials that has been previously initialized to zero.

Expert Answer


Answer to 3. (12 points) Consider an abstract data type (ADT) for polynomials (in a single variable x) whose operations include th…

OR