Question: Using linked list, write a C program to evaluate polynomials: P1(x), P2(x), and P3(x) where P1(x) and P2(x) are input polynomials and P3(x) is obtained

 Using linked list, write a C program to evaluate polynomials: P1(x),P2(x), and P3(x) where P1(x) and P2(x) are input polynomials and P3(x)

Using linked list, write a C program to evaluate polynomials: P1(x), P2(x), and P3(x) where P1(x) and P2(x) are input polynomials and P3(x) is obtained by merging P1(x) and P2(x) in such a manner that the total number of terms in P3(x) is equal to the sum of the number of terms in P1(x) and P2(x) and the highest degree of P3(x) is the smallest integer greater than the sum of the highest degrees of P1(x) and P2(x). Rest of the terms are adjusted accordingly. For example, P1(x) = anxN + a(N-1)2(N-1) + ... + anz and P2(x) = b^2M + b(M-1)2(M-1) +...+boz then P3(x) is obtained as P3(x) = anx(N+M+1) +a(N-1)(N-1+M+1)+ ...+ avr(M+1) +b2M +b(01)(M1) + ... + box. Each node in the linked list correspond to a term in the polynomial. So, in your node structure - you may keep two data components integers pow and coeff; and one pointer to the next node. Input Format: First line mentions K i.e. the number of test cases. Then there are three lines for each test case, In the first two lines of a test case, First number indicate the highest degree of polynomials N and then there are N+1 integers which are the coefficients of polynomial terms in descending order. In the third (and last line) of a test case, there is one integer i.e. value of x for which you need to evaluate the polynomials. (Constraints: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!