• Study Resource
• Explore

Survey

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Fundamental theorem of algebra wikipedia, lookup

Factorization of polynomials over finite fields wikipedia, lookup

System of polynomial equations wikipedia, lookup

Polynomial ring wikipedia, lookup

Cayley–Hamilton theorem wikipedia, lookup

Quartic function wikipedia, lookup

Eisenstein's criterion wikipedia, lookup

Factorization wikipedia, lookup

Gröbner basis wikipedia, lookup

Polynomial greatest common divisor wikipedia, lookup

Polynomial wikipedia, lookup

Horner's method wikipedia, lookup

Resultant wikipedia, lookup

Rook polynomial wikipedia, lookup

Transcript
```Project 1
We can define an abstract data type for single-variable polynomials (with non-negative
N
exponents) by using a list. Let f ( x)  i 0 ai x i . If most of the coefficients ai are
nonzero we could use a simple array to store the coefficients and write routines to
perform addition, subtraction, multiplication, differentiation, and other operations on
these polynomials.
An array implementation would be adequate for dense polynomials, where most of the
terms are present, but if P1 ( x)  3x1000  5 x14  1 and P2 ( x)  10 x1990  2 x1492  11x  5 ,
then the running time is likely to be unacceptable. One cans see that if arrays were used,
then most of the time is spend multiplying zeros and stepping through what amounts to
nonexistent parts of the input polynomials. This is always undesirable.
An alternative is to use a singly linked list. Each term in the polynomial is contained int
one cell, and the cells are stored in decreasing order of exponents. For instance, the linked
lists below represent P1 ( x) and P2 ( x) .
3
10
0
1000
1990
5
1
14
-2
1492
nul
l
0
11
0
1
5
0
Assignment
Starting with the class Skeleton, below, Implement the Polynomial ADT using linked
lists. You may use either the Java LinkedList class, or “roll your own” list/node data
it’s own class. However, you must include an application that demonstrates and tests the
key functionality of your implementation. Your write up should include a discussion of
what you used and the documentation html files generated by javadoc.
nul
l
public class Literal {
// various constructors & accessors (not shown)
double coefficient;
int exponent;
//if you roll your own list, then include “Literal next;”
}
public class Polynomial {
private List terms ; // A list of literals
public Polynomial() {
// constructor to be implemented
}
public void insert term(double coef, int exp){
// to be implemented
}