In: Computer Science
public class Node<T>
{
Public T Item { get; set; }
Public Node<T> Next; { get; set; }
public Node (T item, Node<T> next)
{ … }
}
public class Polynomial
{
// A reference to the first node of a singly linked list
private Node<Term> front;
// Creates the polynomial 0
public Polynomial ( )
{ }
// Inserts term t into the current polynomial in its proper
order
// If a term with the same exponent already exists then the two
terms are added together
public void AddTerm (Term t)
{ … }
// Adds polynomials p and q to yield a new polynomial
public static Polynomial operator + (Polynomial p, Polynomial
q)
{ … }
// Multiplies polynomials p and q to yield a new polynomial
public static Polynomial operator * (Polynomial p, Polynomial
q)
{ … }
// Evaluates the current polynomial at x
public double Evaluate (double x)
{ … }
// Prints the current polynomial
public void Print ( )
{ … }
}
DON'T SOLVE THE FIRST TASK JUST THE ONE AFTER THIS LINE. The first
task is their for reference
C# Please :)
In a separate namespace, the class Polynomial (Version
2) re-implements a polynomial as a linear array
of terms ordered by exponent. Each polynomial is also reduced to
simplest terms, that is, only one term
for a given exponent.
public class Polynomial
{
// P is a linear array of Terms
private Term[ ] P;
…
// Re-implement the six methods of Polynomial (including the
constructor)
…
}
Explanation of Node Class :
Node in java - Is a class which is used to create the individual data holding blocks for various data structure,Which organise data in a non sequential.
Implementation of Node Class :
A node calss can be customized to store one or more data fields and pointer links inside each of the individual objects,depending on the needs of the requierd data structure.
Example of Node Class :
Public Class Node {
Public Node next;
Public Object data;
}
Explanation of Polynomial :
Polynomial are sums and differences - Any variables in the expression must have whole number powers.
Eg: The "Understood" power of 1,as in ,which normally written as .
This Not a polynomial term :
- Because the variable has a negative exponent.
This is a polynomial term :
- Because it accepts all the rules.
The exponent of leading term in the polynomial could be any number
Eg:
It is called Degree of polynomial