Question

In: Computer Science

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)
{ … }
// 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 ( )
{ … }

Please use C# to answer

Solutions

Expert Solution

1.

Creates an empty list L of polynomials

public polynomials()

{

//creation of empty list of Polynomials

List<Polynomial> list=new List<Polynomial>();

(Or) the provided List l

//we can use Any() to check wheather the list is empty or not

bool check=!l.Any();

if(check)

{

Console.WriteLine("the provided list l is empty");

} else

{

Console.WriteLine("The provided list is not empty");

}

2.

Retrieves the polynomial stored at position i in L

//Can be Done by using Item property

public Polynomial Retrieve (int i) (1 mark)
{

l.Item[i];

}

i.e l.item[2] (it will display polynomial which is storred at 2 location)

3.

// Inserts polynomial p into L
public void Insert (Polynomial p) (1 mark)
{

l.Add(p);

}

4.

// Deletes the polynomial at index i
public void Delete (int i) (1 mark)
{

l.RemoveAt(i)0;//which will remove at index i

}

5.

// Returns the number of polynomials in L
public int Size ( )
{

int count=l.Count; // It will provide number of polynomials of the list

return count;

}

6.

// Prints out the list of polynomials
public void Print ( )
{

foreach(Polynomial polynomial in l)

{

Console.Write(polynomial);

}

}


Related Solutions

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) {...
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) {...
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,...
Question 1 price is an instance variable of a class. Inside that class there is a...
Question 1 price is an instance variable of a class. Inside that class there is a method public void change(int price). From inside the method " change" how do we refer to the instance variable price and not the parameter price? Answer: Question 2 A method of a class can access which of the following: 1 global variables in the same scope 2. local variables defined within the method 3. the instance variables of its class 4. its parameters Question...
What is meant by the following statement: “The software implementation process is a conforming instance of...
What is meant by the following statement: “The software implementation process is a conforming instance of the system implementation process, specialized to the particular needs of implementing a software product or service”? What is meant by the following statement: “Detailed design of the interfaces shall permit coding without the need for further information”?
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...
The Hole Class Description: For the Hole class, there are three instance variables: the par for...
The Hole Class Description: For the Hole class, there are three instance variables: the par for the hole, the length of the hole in yards, and a Boolean valued indicator of whether the hole is one in which the players’ full drives will be measured for distance. John clarifies: The length of the hole in yards determines par for the hole. The current standard is: No more than 250 yards Par 3 251 to 470 yards Par 4 471 to...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent. E.g. • in the term 4X2, the coefficient is 4 and the exponent 2 • in -6X8, the coefficient is -6 and the exponent 8 Your class will have a constructor that creates a Term object with a coefficient and exponent passed as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT