
CSC 241 Programming Assignment #5 Fall 2017
The Polynomial ADT
We can define an abstract data type for single-variable polynomials (with non-negative exponents) by using a list. Let . 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 and , 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
Assignment
Starting with the class Skeleton, below, Implement the Polynomial ADT using linked lists. You are Not to use the Java LinkedList class, you should “roll your own†list/node data types.
Your project will be graded automatically, so you must make the Polynomial ADT itâ€s own class. However, you must include an application that demonstrates and tests the key functionality of your implementation. Your write/documentations up should include a discussion of what you used and the documentation html files generated by javadoc.
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
// if you roll your own, then “private Literal head;â€
public Polynomial() {
// constructor to be implemented
}
public void insert term(double coef, int exp){
// to be implemented
}
public Polynomial add(Polynomial rhs) {
// to be implemented
}
public Polynomial multiply(Polynomial rhs) {
// to be implemented
}
public String toString(){
// to be implemented use “^†to signify exponents
}
}
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.
The post programming-assignment-5-2 appeared first on Essay Fount.
What Students Are Saying About Us
.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"
.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."
"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"
