We define ADT POLYNOMIAL which is a special case of the ADT LIST. Each element in the polynomial has two [login to view URL] and [login to view URL] elements of the ADT POLYNOMIAL are organized in a list in decreasing order of the Exponent [login to view URL] operations which should be defined for the ADT POLYNOMIAL are:
* MAKENULL(): Initializes an empty polynomial ( the zero polynomial)
* FIRST() returns the position of the first element of a polynomial
* END() returns the position of the last element of a polynomial
* INSERTEND(s): inserts a new element s at the end of the polynomial
* INSERT(S): inserts a new element s in the polynomial and keeps the decreasing order of the polynomial
* PRINT(): prints the element of a polynomial in order
* EVALUATE(x): returns the value of a polynomial given the value of the parameter is x
* ADD (P, Q, S): returns a polynomial S which is the sum of two polynomials P and Q. ie S=P+Q
* SUB (P, Q, S): returns a polynomial S which is the result of subtracting polynomial Q from polynomial P. ie S=P-Q
* MUL(P, Q, S): returns a polynomial S which is the product of two polynomials P and Q ie S=P*Q
* DIV(P,Q,S,R) returns two polynomials : S, which is the quotient of the division of the polynomials P and Q, and R which is the remainder of this division.
* POW (P n S) : returns a polynomial S which is the n_th power of the polynomial P,S=P(power n)
For each element of an ADT POLYNOMIAL we define the following operations:
* EXP() returns the exponent of the element
* COEF() returns the coefficient of the element
* NEXT() returns the element next to the current one in the polynomial
The above ADT and procedures will be implemented using link list representation in C++.Each element will be presented as a record of three fields, namely, Exp,Coef,and Link,where Link is a pointer
To test the program, use the following polynomials:
A= 2x(cube)??"1, B= 2x(power 4)??"5x(square)+3, C = 2x(power 10)??"6x(square)
Compute the following [login to view URL] each one(and the input polynomials)print the polynomials using a nice format and its value for x=2
Polynomials to be computed are:
D= A+B,
E = A-B,
F = D*E,
G = A(Square),
H = B(square)
I = G-H,
J = F-I,
K = B(cube) ,
L = K/C,
M = K+A
N= M/B