Hey people :)
My final exam is now approaching and I am practicing hard.
I've come accross this task which I have no clue how to solve.
It is about solving a polynomial through a linked list - and I really don't know how to even start. Can somebody help a little? Just show me the way how to do it? :) I'd appriciate it.
1.4. Linked lists
2.A polynomial can be represented by a sorted linked list.
3.public class Polynomial {
4.private SortedLinkedList<Term> poly;
5.// constructors and other methods
6.}
7.Where the Term defines the representation of the polynomial term:
8.public class Term implements Comparable<Term>{
9.private double coeff; // coefficient
10.private int exp; // exponent
11.// constructors and other accessor methods
12.}
13.For example,
14.p(x) = 10 x100 + 5 x20 + 3x + 10
15.xp(x) = 10 x101 + 5 x21 + 3 x2 + 10x
16.Write a static method for the class Polynomial to do the polynomial multiplication by x:
17.public static Polynomial xPolynomial ( Polynomial p )
18.Tip: Followings are some public methods provided by these methods.
19.
20.LinkedList:
21.// ******************PUBLIC OPERATIONS*********************
22.// boolean isEmpty( ) --> Return true if empty; else false
23.// LinkedListIterator zeroth( ) --> Return position to prior to first
24.// LinkedListIterator first( ) --> Return first position
25.// void insert( x, p ) --> Insert x after current iterator position p
26.SortedLinkedList:
27.// void insert( x ) --> Insert x
28.// void insert( x, p ) --> Insert x (ignore p)
29.LinkedListIterator:
30.// void advance( ) --> Advance
31.// boolean isValid( ) --> True if at valid position in list
32.// AnyType retrieve --> Return item in current position