Answered step by step
Verified Expert Solution
Question
1 Approved Answer
void Polynomial::normalize ( ) { if ( degree < 0 ) { terms.clear ( ) ; return; } std::list::iterator it = terms.begin ( ) ;
void Polynomial::normalize
if degree
terms.clear;
return;
std::list::iterator it terms.begin;
while it terms.end
if itcoefficient
it terms.eraseit;
else
it;
if termsbegin terms.end
degree terms.backpower;
else
degree ;
Polynomial::Polynomial
: degree coefficientsnullptr
Polynomial::Polynomial int b int a
: degree coefficientsnew int
coefficients b;
coefficients a;
normalize;
Polynomial::Polynomial Term term
: degreetermpower coefficientsnew inttermpower
for int i ; i degree; i
coefficientsi;
coefficientsdegree term.coefficient;
normalize;
Polynomial::Polynomial int nC int coeff
: degreenC coefficientsnew intnC
for int i ; i degree; i
coefficientsi coeffi;
normalize;
void Polynomial::normalize
while degree && coefficientsdegree
degree;
int Polynomial::getDegree const
return degree;
int Polynomial::getCoeffint power const
if power && power degree
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started