Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs to be coded in PYTHON class PolyType PolyType () # default constructor - _polyPtr is None PolyType (float coef, int exponent); # constructor makes

Needs to be coded in PYTHON

class PolyType

PolyType () # default constructor - _polyPtr is None PolyType (float coef, int exponent); # constructor makes a 1 node polynomial PolyType operator+ (PolyType right) # returns a NEW PolyType of sum of the parameter + self PolyType operator* (PolyType right ) # returns a NEW PolyType of sum of the parameter * self PolyType differ() # differentiation - return a NEW PolyType where coef = ceof * exp & exp -= 1 PolyType integr() # integration (with 0 as the constant) - return a NEW PolyType where exponent + 1 & coef = coef / exponent __str__ # coefficients printed to 2 decimal places

variable TermNode _polyPtr;

class TermNode int exponent float coefficient TermNode next

Note- term nodes are stored in descending order by exponent

Usage example # sample output

poly1 = PolyType() #makes a null polynomial poly2 = PolyType(2,3) #makes the polynomial 2.00x^3 poly3 = PolyType(3,4) # makes the polynomial 3.00x^4 poly1 = poly2 + poly3 # makes poly1 = 3.00x^4 + 2.00x^3 print(poly1) # prints out 3.00x^4 + 2.00x^3 poly3 = poly2*poly1 # sets poly3 to 6.0x^7+4.00x^6 poly4 = poly3.differ() # sets poly4 to 42.00x^6+24.00x^5 poly5 = poly1.integr() # sets poly5 to .60x^5+.50x^4

**PYTHON**

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started