Question

In: Computer Science

public class Node<T> { Public T Item { get; set; } Public Node<T> Next; { get;...

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)

}

Solutions

Expert Solution

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


Related Solutions

public class MyLinked {    static class Node {        public Node (double item, Node...
public class MyLinked {    static class Node {        public Node (double item, Node next) { this.item = item; this.next = next; }        public double item;        public Node next;    }    int N;    Node first;     // remove all occurrences of item from the list    public void remove (double item) {        // TODO    } Write the remove function. Do NOT add any fields to the node/list classes, do...
Use this implementation of Integer node, public class IntegerNode { public int item; public IntegerNode next;...
Use this implementation of Integer node, public class IntegerNode { public int item; public IntegerNode next; public IntegerNode(int newItem) { item = newItem; next = null; } // end constructor public IntegerNode(int newItem, IntegerNode nextNode) { item = newItem; next = nextNode; } // end constructor } // end class IntegerNode You need to implement add( ), delete( ), traverse( ) methods for an ordered linked list. And after insertion and deletion, your linked list will remain ordered. Your code...
public class SinglyLikedList {    private class Node{        public int item;        public...
public class SinglyLikedList {    private class Node{        public int item;        public Node next;        public Node(int item, Node next) {            this.item = item;            this.next = next;        }    }       private Node first;    public void addFirst(int a) {        first = new Node(a, first);    } } 1. Write the method add(int item, int position), which takes an item and a position, and...
Using the textbook implementation of integer node given below; public class IntegerNode { public int item;...
Using the textbook implementation of integer node given below; public class IntegerNode { public int item; public IntegerNode next; public IntegerNode(int newItem) { item = newItem; next = null; } // end constructor public IntegerNode(int newItem, IntegerNode nextNode) { item = newItem; next = nextNode; } // end constructor } // end class IntegerNode You need to implement add( ), delete( ), traverse( ) methods for an ordered linked list. And after insertion and deletion, your linked list will remain...
public class StringNode { private String item; private StringNode next; } public class StringLL { private...
public class StringNode { private String item; private StringNode next; } public class StringLL { private StringNode head; private int size; public StringLL(){ head = null; size = 0; } public void add(String s){ add(size,s); } public boolean add(int index, String s){ ... } public String remove(int index){ ... } } In the above code add(int index, String s) creates a StringNode and adds it to the linked list at position index, and remove(int index) removes the StringNode at position...
in java This class will require the following fields: Node<T> head: the first Node in the...
in java This class will require the following fields: Node<T> head: the first Node in the chain Node<T> tail: the last Node in the chain int size: Keeps a count of the number of Nodes in the chain Your LinkedList class must also support the following public methods. LinkedList(): A default constructor sets both pointers to null and sets the size to 0. int size(): Returns the size of the LinkedList. void push_back(T): Creates a new Node and assigns it...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
please answer as text You are given a Node class and a List class: public class...
please answer as text You are given a Node class and a List class: public class Node {        int           data;        Node       next;        Node(int d, Node n){             data = d;             next = n;       } } public class List{        Node header; } Write a java method insertNodeBefore( ) which takes two integers: int ref which is the data of the node that we need to insert a new node before, and int d which is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT