Question

In: Computer Science

Task 4 The class Polynomials is a collection of polynomials of either implementation stored in an...

Task 4
The class Polynomials is a collection of polynomials of either implementation stored in an instance of the
generic library class List.
class Polynomials
{
private List<Polynomial> L;
// Creates an empty list L of polynomials
public Polynomials ( )
{ … } (1 mark)
// Retrieves the polynomial stored at position i in L
public Polynomial Retrieve (int i) (1 mark)
{ … }
// Inserts polynomial p into L
public void Insert (Polynomial p) (1 mark)
{ … }
// Deletes the polynomial at index i
public void Delete (int i) (1 mark)
{ … }
// Returns the number of polynomials in L
public int Size ( )
{ … } (1 mark)
// Prints out the list of polynomials
public void Print ( )
{ … }
}

Solutions

Expert Solution

Short Summary:

  • Implemented all the methods as per the requirement
  • Attached source code and screenshot

**************Please do upvote to appreciate our time. Thank you!******************

Source Code:

import java.util.ArrayList;
import java.util.List;

/** The class Polynomials is a collection of polynomials of either implementation stored in an instance of the
generic library class List. **/
class Polynomials
{
   private List<Polynomial> L;
   // Creates an empty list L of polynomials
   public Polynomials ( )
   {
       L=new ArrayList<>();  
   }
   // Retrieves the polynomial stored at position i in L
   public Polynomial Retrieve (int i)
   {
       return L.get(i);
   }
   // Inserts polynomial p into L
   public void Insert (Polynomial p)
   {
       L.add(p)   ;
   }
   // Deletes the polynomial at index i
   public void Delete (int i)
   {
       L.remove(i)   ;
   }
   // Returns the number of polynomials in L
   public int Size ( )
   {

       return L.size(); }
   // Prints out the list of polynomials
   public void Print ( )
   {
       for(Polynomial pol:L)
       {
           System.out.println(pol.toString());  
       }
   }


}

Code Screenshot:

**************Please do upvote to appreciate our time. Thank you!******************


Related Solutions

The class Polynomials is a collection of polynomials of either implementation stored in an instance of...
The class Polynomials is a collection of polynomials of either implementation stored in an instance of the generic library class List. class Polynomials { private List L; // Creates an empty list L of polynomials public Polynomials ( ) { … } (1 mark) // Retrieves the polynomial stored at position i in L public Polynomial Retrieve (int i) (1 mark) { … } // Inserts polynomial p into L public void Insert (Polynomial p) (1 mark) { … }...
Task : (Please Answer in C#) Class Polynomials The class Polynomials is a collection of polynomials...
Task : (Please Answer in C#) Class Polynomials The class Polynomials is a collection of polynomials of either implementation stored in an instance of the generic library class List. class Polynomials { private List L; // Creates an empty list L of polynomials public Polynomials ( ) { … } // Retrieves the polynomial stored at position i in L public Polynomial Retrieve (int i) { … } // Inserts polynomial p into L public void Insert (Polynomial p) {...
c++ please Your task is to write the implementation for a class of polynomial operations. Your...
c++ please Your task is to write the implementation for a class of polynomial operations. Your will write the code for: 2 constructors, a destructor, print, addition, multiplication , differentiation and integration of polynomials. The polynomials will be comprised of linked TermNodes. struct TermNode { int exp; // exponent double coef; // coefficient TermNode * next; }; class Polynomial { public: Polynomial (); // default constructor Polynomial (int r, int c); // constructor makes a 1 node polynomial Polynomial(const Polynomial...
Task 2 (1 mark) Transformation of data stored in the relational tables into data stored in...
Task 2 (1 mark) Transformation of data stored in the relational tables into data stored in BSON collection.
Task 1: [10 Marks] Write a function “reverse” in your queue class (linked list implementation) that...
Task 1: [10 Marks] Write a function “reverse” in your queue class (linked list implementation) that reverses the whole queue. In your driver file (main.cpp), create an integer queue, push some values in it, call the reverse function to reverse the queue and then print the queue.
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either...
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either fiction or nonfiction. Forty percent of the books are fiction and 65% are paperbacks, Also, 25% of the fiction books are hardcover. Now, a book is selected at random. a. What is the probability that it is a paperback?
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either...
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either fiction or nonfiction. Forty percent of the books are fiction and 65% are paperbacks, Also, 25% of the fiction books are hardcover. Now, a book is selected at random. a. What is the probability that it is a paperback? b. What is the probability that it is a paperback, given that it is a fiction? c. What is the probability it is a nonfiction,...
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either...
Amazen has a collection of books for sale. They are either paperbacks or hardcovers and either fiction or nonfiction. Forty percent of the books are fiction and 65% are paperbacks, Also, 25% of the fiction books are hardcover. Now, a book is selected at random. a. What is the probability that it is a paperback? b. What is the probability that it is a paperback, given that it is a fiction? c. What is the probability it is a nonfiction,...
1. Let W be the collection of polynomials, p(x), for which p'(5)=0 (the derivative of the...
1. Let W be the collection of polynomials, p(x), for which p'(5)=0 (the derivative of the polynomial when x = 5 is 0). State two polynomials that would belong to this set, W. State one polynomial that does not belong to this set. Is W a subspace of the vector space containing all polynomial functions? That is, is this subset of polynomials closed under addition and scalar multiplication, and does it contain a zero vector? Justify your answer. (You do...
Task 4 . . . . . . . . . . . . . ....
Task 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Consider a disk drive with 2,000 tracks, numbered 0 to 1,999. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT