Question: A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial

A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X-3 X-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X +6X +6 8X-7X+6X+9X-8X+9 26X7X-X+15X-8X+15 8X-7X5+6X +6 8X-7X +6X +9X-8 X +6X+17X-X -2 8X-6+5X +6X +8X-7X+6X 9X-6X+5X+18X-9 8X-7X7+14X+5X+26X6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2); A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X-3 X-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X +6X +6 8X-7X+6X+9X-8X+9 26X7X-X+15X-8X+15 8X-7X5+6X +6 8X-7X +6X +9X-8 X +6X+17X-X -2 8X-6+5X +6X +8X-7X+6X 9X-6X+5X+18X-9 8X-7X7+14X+5X+26X6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2);
Step by Step Solution
3.29 Rating (161 Votes )
There are 3 Steps involved in it
It looks like youre asking for help developing a C program to add two polynomials represented as linked lists The question specifies an equation class ... View full answer
Get step-by-step solutions from verified subject matter experts
