C++ question. I am a little stuck. Thank you for the help, I will upvote Problem: Consider the ADT polynomial -- in a si
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
C++ question. I am a little stuck. Thank you for the help, I will upvote Problem: Consider the ADT polynomial -- in a si
question. I am a little stuck. Thank you for the help, I will upvote Problem: Consider the ADT polynomial -- in a single variable x -- whose operations include the following: degree() // returns the degree of the polynomial coefficient(power) // returns the coefficient of the xpower term. changeCoefficient(newCoefficient, power) // replaces the coefficient of the xpower term with newCoefficient. 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 (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.changeCoefficient(-3, 7) changes the polynomial p to -3x7 + 4x5 + 7x3 - x2 + 9 Question: Using these ADT operations: a) Increase the coefficient of the x term by 8 b) Compute the sum of two polynomials.
C++