Question: Write a JAVA singly linked list program to accomplish addition, subtraction, and multiplication of two polynomials . Each term will be a node in the

Write a JAVA singly linked list program to accomplish addition, subtraction, and multiplication of two polynomials . Each term will be a node in the list.

After you parse the strings, you should insert the terms in order by power into your list. You should implement insertion sort for this part. An ordered list will be helpful when it comes to adding and subtracting.

The input will be two polynomials in string form:

X^5+2X^2+3X^3+4X^4

2X^2+4X

The output will should be:

Sum:X^5 + 4.0 X^4 + 3.0 X^3 + 4.0 X^2 + 4.0 X

Difference: X^5 + 4.0 X^4 + 3.0 X^3 -4.0 X

Product: 2.0 X^7 + 12.0 X^6 + 22.0 X^5 + 16.0 X^4 + 8.0 X^3

1) Term class is used to store your term for the polynomial. It should contain both the coefficient and power.

2) The node class will hold a term object as its data

3) The LinkedList class will be a list of all the terms in the polynomial. The class implements the LinkedList Interface

4) The Polynomial Class hold the linked list that is associated with that polynomial. It implements the Polynomial interface. This is where all the arithmetic will be done.

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!