Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following polynomial f ( x ) = 2 x 6 + 5 x 3 + x 2 + 6 can be represented as array

The following polynomial f(x)=2x6+5x3+x2+6 can be represented as array-based dynamically allocated memory,
storing the coefficients of each term in the subscript equal to an exponent. The array representation is in the language
C++ :
int *myPoly= nullptr;
myPoly = new int [*degree+1];
(*myPoly+0)(*myPoly+1)(*myPoly+2)(*myPoly+3)(*myPoly+4)(*myPoly+5)(*myPoly+6)
{:[6,0,1,5,0,0]
2
To evaluate a polynomial at an x value, for x=3
f(x)=2(3)6+5(3)5+1(3)2+6(3)0=178
Output Program:
Enter the degree of the polynomial: 6
Enter the coefficient of x6:2
Enter the coefficient of x5:0
Enter the coefficient of x4:0
Enter the coefficient of x3:5
Enter the coefficient of x2:1
Enter the coefficient of x1:0
Enter the coefficient of x0:6
Enter the value to evaluate the polynomial: 2
P(2) is 178
The Polynomial is 2x6+5x3+1x2+6x0+
Press any key to continue ...
Student Instructions:
Complete the instructions missing in the following program.
#include iostream >The following polynomial f(x)=2x^6+5x^3+x^2+6 can be represented as array-based dynamically allocated memory, storing the coefficients of each term in the subscript equal to an exponent. The array representation is in the language C++:
int *myPoly = nullptr;
myPoly = new int[*degree +1];
(*myPoly+0)(*myPoly+1)(*myPoly+2)(*myPoly+3)(*myPoly+4)(*myPoly+5)(*myPoly+6)
6015002
To evaluate a polynomial at an x value, for x=3
f(x)=2(3)^6+5(3)^5+1(3)^2+6(3)^0=178
Output Program:
Enter the degree of the polynomial: 6
Enter the coefficient of x^6: 2
Enter the coefficient of x^5: 0
Enter the coefficient of x^4: 0
Enter the coefficient of x^3: 5
Enter the coefficient of x^2: 1
Enter the coefficient of x^1: 0
Enter the coefficient of x^0: 6
Enter the value to evaluate the polynomial: 2
P(2) is 178
The Polynomial is 2x^6+5x^3+1x ^2+6x^0+
Press any key to continue ...
Student Instructions:
Complete the instructions missing in the following program.
#include iostream>
using namespace: :std;
int * getcoefficients(int *degree){
int *myPoly = nullptr;
myPoly = new int[*degree +1];
for (int i =*degree; i >=0; i--){
cout "Enter the coefficient of x^">*degree;
// define dynamic memory allocated for all variables
myPoly = getCoefficients (//write the argument missing);
cout "Enter the value to evaluate the polynomial: ";
// get the x value
fx = EvaluatePoly (//write the arguments missing );
// show f(x) value
displayPoly(myPoly, degree);
//free the memory
Return 0;
}//end main
image text in transcribed

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

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions