subject

You are to write a class named Polynomial. In what follows, we do not describe all the implementation details, but just provide the main functionality that must be provided by the class. Your class will be tested using this
functionality. If it is indicated that you MUST use a structure or perform a certain task in the class or in a function, do
so. Otherwise, you are free to make the choice by yourself. Of course, you are expected to perform good
programming practices of object oriented programming, e. g. conforming data encapsulation principle.
IMPORTANT: Recall how to allocate pointers to objects by using the keyword new along with a constructor.
(1) An object of the class Polynomial represents a mathematical polynomial in the usual sense. Here are some
examples of polynomials expressed by starting from the exponent 0 (which represents the constant of the
polynomial) and listing the terms in ascending exponents:
3 + x + x^3 + 7*x^6
x^2 + 1000*x^4
Here x^k represents x raised to the power k, and * is the multiplication operator. Note that when the coefficient of
a specific term is 0, we do not list it for saving space. Thus, for example, the second polynomial above is in fact
0 + 0*x + x^2 + 0*x^3 + 1000*x^4
But we only list the two non-zero terms. Note also that we do not write the coefficient and exponent 1.
(2) The class Polynomial MUST keep vector objects of C++ to represent a polynomial as above. You may
assume that the coefficients of the polynomial are integers. Note that in order to represent a term, you must keep
both the exponent and the coefficient. Thus, it might be a good idea to use two different data structures, one for
exponents, and one for coefficients. For example, the second polynomial above might have the values [2, 4] in the
exponents vector, and [1, 1000] in the coefficients vector.
Provide two constructors, the default constructor creating the 0 polynomial, and the other taking two vectors
(exponents and coefficients) representing the polynomial. Do not forget the destructor.
(3) The class Polynomial has the following member function
Polynomial *add(Polynomial *p1, Polynomial *p2);
It adds the polynomials represented by p1 and p2, and returns a new Polynomial object representing the result.
Please, BE CAREFUL: You should not represent the terms with coefficient 0. Furthermore, if there are terms in one
polynomial not appearing in the other, you may have to create new terms in the result.
(4) The class Polynomial has the following member function
Polynomial *subtract(Polynomial *p1, Polynomial *p2);
It subtracts the polynomial p2 from p1, and returns a new Polynomial object representing the result. [Hint:
This is easy once you implement add].(5) The class Polynomial has the following member function
Polynomial *multiply(Polynomial *p1, Polynomial *p2);
It multiplies the polynomials represented by p1 and p2, and returns a new Polynomial object representing the
result. Please, BE CAREFUL: Multiplication of polynomials are more complicated than addition. If you do not know
how to do this, please learn it from an appropriate source. This is usually taught in high school.
(6) The class Polynomial has the following member function
string toString();
This prints out the underlying Polynomial object, based on the information contained in the vectors0, in the
format given in 1).

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
How does a policy manual an organization? a. it boost productivity. b. it create awareness in employees about the organization’s values. c. it employees achieve targets. d. it safeguards the organization from liabilities.
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
How can you repin an image on your pinterest pin board a. click on the "repin" button b. click on the "add pin" button c. click on the "upload a pin" button d. click on the "save pin" button.
Answers: 2
question
Computers and Technology, 23.06.2019 05:00
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
You know the right answer?
You are to write a class named Polynomial. In what follows, we do not describe all the implementatio...
Questions
question
Mathematics, 23.02.2021 01:00
question
Social Studies, 23.02.2021 01:00
question
Arts, 23.02.2021 01:00
question
Geography, 23.02.2021 01:00
Questions on the website: 13722363