Constructing a polynomial given an array of


A polynomial of a real valued variable x is an expression of the form a

n x n + an-1xn-1 + ... + a1x1+ a0

where a0 , ..., an are real constants, called coefficients.

For instance, 2.5 x 3 +1.2x-5 is a polynomial of x with a3=2.5, a2=0, a1=1.2 and a0=-5.

In this project, you are required to develop a class named Polynomial that supports symbolic manipulation of polynomials of a fixed variable x, that is, all polynomials are polynomials of the same variable x. Your class must at least support operations for

1. Constructing a polynomial given an array of coefficients. For example, given the float point number array {2.5,0.0,1.2,-5}, the operation constructs a Polynomial  object representing 2.5x3+1.2x-5.

This is a constructor.

2. Adding one polynomial to another. For example, if this object represents 2.5x3+1.2x-5 then adding another object representing 7x4+2x3+x2+3 to this object 

changes this object so that it represents 7x4+5.5x3+x2+1.2x-2.

Note that the ranks (the largest exponent) of the two polynomials are not necessary the same.

3. Multiplying one polynomial by another. For example, if this object represents

2x2+x-5 then multiplying it by another object representing 3x3+x2+3 changes thisobject so that it represents 6x5+5x4-14x3+x2+3x-15. Again the ranks of the two polynomials are not necessary the same.

4. Evaluating a polynomial for a given value for x. For instance, if this object represents 2x2+x-5 then evaluating it for x=2 yields 5.

5. Converting a Polynomial object to a string so that the Polynomial object can be displayed. If this object represents 3x3+x2-1 then the method should return "3*x^3 + x^2 - 1" although "3*x^3 + 1*x^2 + 0*x^1 + (-1)" is acceptable

1. Specify, design and implement Polynomial. Your implementation must use linked lists to represent polynomials.

2. Write an interactive test program that tests all the public methods of the Polynomial class.

Please submit the following.

 Analysis: test data;

 Design:

1. Class diagrams showing representation of data;

2. A class invariant for each class;

3. Pre/Post conditions for required operations;

4. Algorithms for required operations. Algorithms can be described in English,

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Constructing a polynomial given an array of
Reference No:- TGS01122383

Now Priced at $45 (50% Discount)

Recommended (91%)

Rated (4.3/5)