Question
In java, Please implement the ADT for a Polynomial. An array is used to store the different coefficients of the polynomial. The size of the
In java,
Please implement the ADT for a Polynomial.
An array is used to store the different coefficients of the polynomial. The size of the array is degree +1, where degree is the degree of the polynomial.
For example, 3x + 5x2 + 7x4 is: (below)
3 | 0 | 5 | 0 | 7 |
The ADT mandates the following static class operations:
zero() -> return a new polynomial p(x) = 0 isZero(poly) -> returns true if the polynomial is zero, false otherwise coeff(poly, exponent) -> return the coefficient for the given exponent or 0 if it does not exist
leadExp(poly) -> return the lead exponent of the given polynomial
remove(poly, exponent) -> Remove the corresponding term from the polynomial and return it,
otherwise return -1
add(poly1, poly2) -> return the poly that is the addition of poly1 and poly2 mult(poly1, poly2) -> return poly1 x poly2 //THIS IS PROBABLY HARDEST
In addition, polynomials should be cloneable and should implement a proper equals method and toString method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started