Here in the given question,
Dividend =x3−3x2+x+2
Quotient =x−2
Remainder =−2x+4
Divisor = g(x)
We know that,
Dividend = Quotient × Divisor + Remainder
⇒x3−3x2+x+2=(x−2)×g(x)+(−2x+4)⇒x3−3x2+x+2−(−2x+4)=(x−2)×g(x)
⇒x3−3x2+3x−2=(x−2)×g(x)
⇒g(x)=(x3−3x2+3x−2)(x−2)
∴ g(x)=(x2−x+1)