Question: Polynomial add or subtract Write a program that adds and subtracts two polynomials. Implement the algorithm tour different ways. The first two implementations will use

Polynomial add or subtract
 Polynomial add or subtract Write a program that adds and subtracts

Write a program that adds and subtracts two polynomials. Implement the algorithm tour different ways. The first two implementations will use arrays and the third will use pointers. The forth is a set of linked lists in an array. Use the following interface for the 4 classes: Public interface Polynomiallnterface {Polynomial Interface add(Polynomiallnterface other).//Effect: Adds value to owner of addPolynomial method.//Postcondition Return value - this + value Polynomiallntcrface subtract(Polynomial Interface other);//Effect: Subtracts value from owner of addPohnomial method.//Postcondition Return value = this + value, void readPolynomial();//Postcondition: polynomial read String toString();//Postcondition: polyomial converted to string The class must be able to read and print polynomials Example 4X^4 + X^3 - 3 +4X^4 - 2X^3 + 4X/8X^4 - X^3 + 4X - 3 The four ways to implement the requirements March 27 Monday Create an array or Arras List holding coefficients with the arras indexes as exponents April 5. Wednesday Create and array or ArrayList of nodes. each node bolding a term of the polynomial April 17. Monday Use a linked list ft terms using pointers April 26. Wednesday Polynomials are linked lists in one static array. Implementations 2. 3, and 4 require a class that will encapsulate a polynomial term unique to that particular implementation The string from the constructor is a polynomial that each implementation must take apart and store each term in sorted order All three implementations will follow the same basic algorithm to add two sorted polynomials. This algorithm resembles the method merge() found on page 694 of the text A picture of the fourth project is figure 7.13 page 492 One array is used to store multiple polynomial instances and the free store this array must be in the polynomial class and declared static so that It is available to all polynomial instances and initialized once by the first instance of a polynomial. There are two challenges in the first implementation The lint is converting the polynomial string given in the constructor into the terms of the polynomial The second is taking the internal representation of the polynomial and converting it back to a string in the toString() method The other three implementation will modify slightly the code from the first implementation for their constructor and toString() methods. Your code must use the Denso class that I will provide. Below is the syntax for working with the interface: public PolynomialInterface add(PolynomialInterface other) {ArrayWithExponentAs Index answer = new ArraywithExponentAsIndex (); ArrayWithExponentAsIndex parameter = (ArraywithExponentAsIndex)other

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!