Apolynomial of a single variablex with integer coefficients is an expression of the form
p(x)= C0+C2x + c2 x2 +..+cn xn whereci,i=0, 1, ...,n, are integers.
Consider a sparse implementation of the ADT polynomials up to thent,J degree that stores only the terms with nonzero coefficients. For example, the polynomial
p=-3x7 + 4x5 + 7x3 - x2 + 9
can be represented using the linked list shown in Figure. Complete the classPolynomial based on this sparse implementation. AssumePolynomial has the following methods:
Polynomial()
Constructs a new polynomial of degree zero.
int getCoefficient(int power)
Returns an integer representing the coefficient of thexfwwa term.
void setCoefficient(int coef,int power)
Sets the coefficient of thexPn]]'u term tocoef.
String toString()
Returns thestring representation of the polynomial. For example,3x~ + 2x +1 would be returned as 3 *x^2 + 2*x + 1 or, more simply, 3x^ 2 + 2x + 1. Any term whose coefficient is zero should not appear in the string unless the polynomial has only a single constant term of zero.
double evaluate(double x)
Evaluates the polynomial for the valuex and returns the resultp(x).
Polynomialdouble add(Polynomial other)
Add to diis polynomial the polynomial other and return the resulting polynomial.
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.