Course Solutions Uncategorized (Solved) : Java Data Structures Assignment Need Change Linked List Polynomial Map Polynomial Using Ma Q30447391 . . . .

(Solved) : Java Data Structures Assignment Need Change Linked List Polynomial Map Polynomial Using Ma Q30447391 . . . .

 

JAVA Data structures assignment. Need to change this linked-listpolynomial into a MAP polynomial, using Map<Integer, Double>for the coefficients. Thank you!

Following is the code:

import java.util.Iterator;

import java.util.LinkedList;

import java.util.ListIterator;

public class Polynomial {

LinkedList<Term> terms;

public static void main(String[] args) {
Polynomial p = new Polynomial(new Term(-10, 0));
p.print();
p.add(new Polynomial(new Term(-1, 1)));
p.print();
p.add(new Polynomial(new Term(9, 7)));
p.print();
p.add(new Polynomial(new Term(5, 10)));
p.print();
Polynomial q = p.multiply(p);
q.print();
}

public Polynomial() {
terms = new LinkedList<>();
}

public Polynomial(Term t) {
terms = new LinkedList<>();
terms.add(t);
}

public void add(Polynomial p) {
int t = 0;
boolean added;
Term current;
for (Term newTerm : p.terms) {
added = false;
while (!added && t < terms.size())
current = terms.get(t);
if (current.getPower() == newTerm.getPower())
{
current.addIfSamePower(newTerm);
added = true;
} else if (newTerm.getPower() > current.getPower())
{
terms.add(t, new Term(newTerm.getCoefficient(),newTerm.getPower()));
added =

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Answered) : The Campaign 4(Answered) : The Campaign 4

<h3>Question Description</h3> <ol><li>How much does it cost to run for office in Texas?<ol><li>https://www.texastribune.org/2017/03/01/heres-how-much-texas-candidates-spent-vote-general-election/</li><li>How will you raise money? (read this handy info from the Texas Democratic Party before you violate any